[llvm] r219016 - Add unit tests to verify Hexagon emission.
Sid Manning
sidneym at codeaurora.org
Fri Oct 3 13:33:04 PDT 2014
Author: sidneym
Date: Fri Oct 3 15:33:03 2014
New Revision: 219016
URL: http://llvm.org/viewvc/llvm-project?rev=219016&view=rev
Log:
Add unit tests to verify Hexagon emission.
Add the test cases I overlooked, part of the original commit,
http://reviews.llvm.org/D5523
Added:
llvm/trunk/unittests/MC/Hexagon/
llvm/trunk/unittests/MC/Hexagon/CMakeLists.txt
llvm/trunk/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp
Added: llvm/trunk/unittests/MC/Hexagon/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/MC/Hexagon/CMakeLists.txt?rev=219016&view=auto
==============================================================================
--- llvm/trunk/unittests/MC/Hexagon/CMakeLists.txt (added)
+++ llvm/trunk/unittests/MC/Hexagon/CMakeLists.txt Fri Oct 3 15:33:03 2014
@@ -0,0 +1,10 @@
+set(LLVM_LINK_COMPONENTS
+ HexagonCodeGen
+ )
+
+include_directories (${LLVM_MAIN_SRC_DIR}/lib/Target/Hexagon)
+include_directories (${LLVM_BINARY_DIR}/lib/Target/Hexagon)
+
+add_llvm_unittest(HexagonTests
+ HexagonMCCodeEmitterTest.cpp
+ )
Added: llvm/trunk/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp?rev=219016&view=auto
==============================================================================
--- llvm/trunk/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp (added)
+++ llvm/trunk/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp Fri Oct 3 15:33:03 2014
@@ -0,0 +1,53 @@
+#include "gtest/gtest.h"
+
+#include <memory>
+
+#include "llvm/MC/MCCodeEmitter.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
+
+#include "MCTargetDesc/HexagonMCInst.h"
+#include "MCTargetDesc/HexagonMCTargetDesc.h"
+
+namespace {
+class TestEmitter {
+public:
+ TestEmitter() : Triple("hexagon-unknown-elf") {
+ LLVMInitializeHexagonTargetInfo();
+ LLVMInitializeHexagonTarget();
+ LLVMInitializeHexagonTargetMC();
+ std::string error;
+ Target = llvm::TargetRegistry::lookupTarget("hexagon", error);
+ assert(Target != nullptr && "Expected to find target");
+ assert(error.empty() && "Error should be empty if we have a target");
+ RegisterInfo = Target->createMCRegInfo(Triple);
+ assert(RegisterInfo != nullptr && "Expecting to find register info");
+ AsmInfo = Target->createMCAsmInfo(*RegisterInfo, Triple);
+ assert(AsmInfo != nullptr && "Expecting to find asm info");
+ Context = new llvm::MCContext(AsmInfo, RegisterInfo, nullptr);
+ assert(Context != nullptr && "Expecting to create a context");
+ Subtarget = Target->createMCSubtargetInfo(Triple, "hexagonv4", "");
+ assert(Subtarget != nullptr && "Expecting to find a subtarget");
+ InstrInfo = Target->createMCInstrInfo();
+ assert(InstrInfo != nullptr && "Expecting to find instr info");
+ Emitter = Target->createMCCodeEmitter(*InstrInfo, *RegisterInfo, *Subtarget,
+ *Context);
+ assert(Emitter != nullptr);
+ }
+ std::string Triple;
+ llvm::Target const *Target;
+ llvm::MCRegisterInfo *RegisterInfo;
+ llvm::MCAsmInfo *AsmInfo;
+ llvm::MCContext *Context;
+ llvm::MCSubtargetInfo *Subtarget;
+ llvm::MCInstrInfo *InstrInfo;
+ llvm::MCCodeEmitter *Emitter;
+};
+TestEmitter Emitter;
+}
+
+TEST(HexagonMCCodeEmitter, emitter_creation) {
+ ASSERT_NE(nullptr, Emitter.Emitter);
+}
More information about the llvm-commits
mailing list