summaryrefslogtreecommitdiff
path: root/unittests/MC
diff options
context:
space:
mode:
authorColin LeMahieu <colinl@codeaurora.org>2014-11-04 00:14:36 +0000
committerColin LeMahieu <colinl@codeaurora.org>2014-11-04 00:14:36 +0000
commit38d3e4d5d82bdd2b08d004e403b3de61223a013d (patch)
treeb9daa75f90acdd2c314737e2c73a93f3125e2e2e /unittests/MC
parent60c2a98db4545717a546976db723400e3b1f9409 (diff)
[Hexagon] Reverting 220584 to address ASAN errors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/MC')
-rw-r--r--unittests/MC/CMakeLists.txt6
-rw-r--r--unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp53
2 files changed, 59 insertions, 0 deletions
diff --git a/unittests/MC/CMakeLists.txt b/unittests/MC/CMakeLists.txt
index 271309c0859..95a3fff2b52 100644
--- a/unittests/MC/CMakeLists.txt
+++ b/unittests/MC/CMakeLists.txt
@@ -7,3 +7,9 @@ add_llvm_unittest(MCTests
StringTableBuilderTest.cpp
YAMLTest.cpp
)
+
+foreach(t ${LLVM_TARGETS_TO_BUILD})
+ if (IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/${t}")
+ add_subdirectory(${t})
+ endif (IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/${t}")
+endforeach()
diff --git a/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp b/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp
new file mode 100644
index 00000000000..958a21fa3fc
--- /dev/null
+++ b/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp
@@ -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);
+}