Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 1 | //===-- ARMAsmPrinter.cpp - ARM LLVM assembly writer ----------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the "Instituto Nokia de Tecnologia" and |
| 6 | // is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | // |
| 11 | // This file contains a printer that converts from our internal representation |
| 12 | // of machine-dependent LLVM code to GAS-format ARM assembly language. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "ARM.h" |
| 17 | #include "ARMInstrInfo.h" |
| 18 | #include "llvm/Constants.h" |
| 19 | #include "llvm/DerivedTypes.h" |
| 20 | #include "llvm/Module.h" |
| 21 | #include "llvm/Assembly/Writer.h" |
| 22 | #include "llvm/CodeGen/AsmPrinter.h" |
| 23 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 24 | #include "llvm/CodeGen/MachineConstantPool.h" |
| 25 | #include "llvm/CodeGen/MachineInstr.h" |
| 26 | #include "llvm/Target/TargetMachine.h" |
| 27 | #include "llvm/Support/Mangler.h" |
| 28 | #include "llvm/ADT/Statistic.h" |
| 29 | #include "llvm/ADT/StringExtras.h" |
| 30 | #include "llvm/Support/CommandLine.h" |
| 31 | #include "llvm/Support/MathExtras.h" |
| 32 | #include <cctype> |
| 33 | #include <iostream> |
| 34 | using namespace llvm; |
| 35 | |
| 36 | namespace { |
| 37 | Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); |
| 38 | |
| 39 | struct ARMAsmPrinter : public AsmPrinter { |
| 40 | ARMAsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) { |
| 41 | Data16bitsDirective = "\t.half\t"; |
| 42 | Data32bitsDirective = "\t.word\t"; |
| 43 | Data64bitsDirective = 0; |
| 44 | ZeroDirective = "\t.skip\t"; |
| 45 | CommentString = "!"; |
| 46 | ConstantPoolSection = "\t.section \".rodata\",#alloc\n"; |
| 47 | } |
| 48 | |
| 49 | /// We name each basic block in a Function with a unique number, so |
| 50 | /// that we can consistently refer to them later. This is cleared |
| 51 | /// at the beginning of each call to runOnMachineFunction(). |
| 52 | /// |
| 53 | typedef std::map<const Value *, unsigned> ValueMapTy; |
| 54 | ValueMapTy NumberForBB; |
| 55 | |
| 56 | virtual const char *getPassName() const { |
| 57 | return "ARM Assembly Printer"; |
| 58 | } |
| 59 | |
| 60 | void printOperand(const MachineInstr *MI, int opNum); |
| 61 | void printMemOperand(const MachineInstr *MI, int opNum, |
| 62 | const char *Modifier = 0); |
| 63 | void printCCOperand(const MachineInstr *MI, int opNum); |
| 64 | |
| 65 | bool printInstruction(const MachineInstr *MI); // autogenerated. |
| 66 | bool runOnMachineFunction(MachineFunction &F); |
| 67 | bool doInitialization(Module &M); |
| 68 | bool doFinalization(Module &M); |
| 69 | }; |
| 70 | } // end of anonymous namespace |
| 71 | |
| 72 | #include "ARMGenAsmWriter.inc" |
| 73 | |
| 74 | /// createARMCodePrinterPass - Returns a pass that prints the ARM |
| 75 | /// assembly code for a MachineFunction to the given output stream, |
| 76 | /// using the given target machine description. This should work |
| 77 | /// regardless of whether the function is in SSA form. |
| 78 | /// |
| 79 | FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o, |
| 80 | TargetMachine &tm) { |
| 81 | return new ARMAsmPrinter(o, tm); |
| 82 | } |
| 83 | |
| 84 | /// runOnMachineFunction - This uses the printMachineInstruction() |
| 85 | /// method to print assembly for each instruction. |
| 86 | /// |
| 87 | bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) { |
| 88 | assert(0 && "not implemented"); |
| 89 | // We didn't modify anything. |
| 90 | return false; |
| 91 | } |
| 92 | |
| 93 | void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum) { |
| 94 | assert(0 && "not implemented"); |
| 95 | } |
| 96 | |
| 97 | void ARMAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum, |
| 98 | const char *Modifier) { |
| 99 | assert(0 && "not implemented"); |
| 100 | } |
| 101 | |
| 102 | void ARMAsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) { |
| 103 | assert(0 && "not implemented"); |
| 104 | } |
| 105 | |
| 106 | bool ARMAsmPrinter::doInitialization(Module &M) { |
| 107 | Mang = new Mangler(M); |
| 108 | return false; // success |
| 109 | } |
| 110 | |
| 111 | bool ARMAsmPrinter::doFinalization(Module &M) { |
| 112 | assert(0 && "not implemented"); |
| 113 | AsmPrinter::doFinalization(M); |
| 114 | return false; // success |
| 115 | } |