mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6056 91177308-0d34-0410-b5e6-96231b3b80d8
		
			
				
	
	
		
			62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| //===-- MachineCodeEmitter.cpp - Implement the MachineCodeEmitter itf -----===//
 | |
| //
 | |
| // This file implements the MachineCodeEmitter interface.
 | |
| //
 | |
| //===----------------------------------------------------------------------===//
 | |
| 
 | |
| #include "llvm/CodeGen/MachineCodeEmitter.h"
 | |
| #include "llvm/CodeGen/MachineFunction.h"
 | |
| #include "llvm/Function.h"
 | |
| #include <iostream>
 | |
| 
 | |
| namespace {
 | |
|   struct DebugMachineCodeEmitter : public MachineCodeEmitter {
 | |
|     void startFunction(MachineFunction &F) {
 | |
|       std::cout << "\n**** Writing machine code for function: "
 | |
|                 << F.getFunction()->getName() << "\n";
 | |
|     }
 | |
|     void finishFunction(MachineFunction &F) {
 | |
|       std::cout << "\n";
 | |
|     }
 | |
|     void startBasicBlock(MachineBasicBlock &BB) {
 | |
|       std::cout << "\n--- Basic Block: " << BB.getBasicBlock()->getName()<<"\n";
 | |
|     }
 | |
| 
 | |
|     void startFunctionStub(const Function &F, unsigned StubSize) {
 | |
|       std::cout << "\n--- Function stub for function: " << F.getName() << "\n";
 | |
|     }
 | |
|     void *finishFunctionStub(const Function &F) {
 | |
|       std::cout << "\n";
 | |
|       return 0;
 | |
|     }
 | |
|     
 | |
|     void emitByte(unsigned char B) {
 | |
|       std::cout << "0x" << std::hex << (unsigned int)B << std::dec << " ";
 | |
|     }
 | |
|     void emitPCRelativeDisp(Value *V) {
 | |
|       std::cout << "<disp %" << V->getName() << ": 0xXX 0xXX 0xXX 0xXX> ";
 | |
|     }
 | |
|     void emitGlobalAddress(GlobalValue *V, bool isPCRelative) {
 | |
|       std::cout << "<addr %" << V->getName() << ": 0xXX 0xXX 0xXX 0xXX> ";
 | |
|     }
 | |
|     void emitGlobalAddress(const std::string &Name, bool isPCRelative) {
 | |
|       std::cout << "<addr %" << Name << ": 0xXX 0xXX 0xXX 0xXX> ";
 | |
|     }
 | |
| 
 | |
|     void emitFunctionConstantValueAddress(unsigned ConstantNum, int Offset) {
 | |
|       std::cout << "<addr const#" << ConstantNum;
 | |
|       if (Offset) std::cout << " + " << Offset;
 | |
|       std::cout << "> ";
 | |
|     }
 | |
|   };
 | |
| }
 | |
| 
 | |
| 
 | |
| /// createDebugMachineCodeEmitter - Return a dynamically allocated machine
 | |
| /// code emitter, which just prints the opcodes and fields out the cout.  This
 | |
| /// can be used for debugging users of the MachineCodeEmitter interface.
 | |
| ///
 | |
| MachineCodeEmitter *MachineCodeEmitter::createDebugMachineCodeEmitter() {
 | |
|   return new DebugMachineCodeEmitter();
 | |
| }
 |