mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	Add the test cases I overlooked, part of the original commit, http://reviews.llvm.org/D5523 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219016 91177308-0d34-0410-b5e6-96231b3b80d8
		
			
				
	
	
		
			54 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #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);
 | |
| }
 |