diff options
| author | Sid Manning <sidneym@codeaurora.org> | 2014-10-03 20:33:03 +0000 | 
|---|---|---|
| committer | Sid Manning <sidneym@codeaurora.org> | 2014-10-03 20:33:03 +0000 | 
| commit | 50600f39ab3613e7748720597c94604af9fa3051 (patch) | |
| tree | 6f1d67e0788bd73a1bf008bdc543e14f65954d68 /llvm/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp | |
| parent | adc41ca4efc187bdac25030206e6da32c2a9eff2 (diff) | |
| download | bcm5719-llvm-50600f39ab3613e7748720597c94604af9fa3051.tar.gz bcm5719-llvm-50600f39ab3613e7748720597c94604af9fa3051.zip | |
Add unit tests to verify Hexagon emission.
Add the test cases I overlooked, part of the original commit,
http://reviews.llvm.org/D5523
llvm-svn: 219016
Diffstat (limited to 'llvm/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp')
| -rw-r--r-- | llvm/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp | 53 | 
1 files changed, 53 insertions, 0 deletions
| diff --git a/llvm/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp b/llvm/unittests/MC/Hexagon/HexagonMCCodeEmitterTest.cpp new file mode 100644 index 00000000000..958a21fa3fc --- /dev/null +++ b/llvm/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); +} | 

