Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 1 | //===-- SPUAsmPrinter.cpp - Print machine instrs to Cell SPU assembly -------=// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains a printer that converts from our internal representation |
| 11 | // of machine-dependent LLVM code to Cell SPU assembly language. This printer |
| 12 | // is the output mechanism used by `llc'. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #define DEBUG_TYPE "asmprinter" |
| 17 | #include "SPU.h" |
| 18 | #include "SPUTargetMachine.h" |
| 19 | #include "llvm/Constants.h" |
| 20 | #include "llvm/DerivedTypes.h" |
| 21 | #include "llvm/Module.h" |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/AsmPrinter.h" |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 23 | #include "llvm/CodeGen/MachineModuleInfo.h" |
Chris Lattner | 6c2f9e1 | 2009-08-19 05:49:37 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCStreamer.h" |
Chris Lattner | af76e59 | 2009-08-22 20:48:53 +0000 | [diff] [blame] | 25 | #include "llvm/MC/MCAsmInfo.h" |
Chris Lattner | 325d3dc | 2009-09-13 17:14:04 +0000 | [diff] [blame] | 26 | #include "llvm/MC/MCSymbol.h" |
Chris Lattner | d62f1b4 | 2010-03-12 21:19:23 +0000 | [diff] [blame] | 27 | #include "llvm/Target/Mangler.h" |
Chris Lattner | f014412 | 2009-07-28 03:13:23 +0000 | [diff] [blame] | 28 | #include "llvm/Target/TargetLoweringObjectFile.h" |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 29 | #include "llvm/Target/TargetInstrInfo.h" |
| 30 | #include "llvm/Target/TargetOptions.h" |
Chris Lattner | f014412 | 2009-07-28 03:13:23 +0000 | [diff] [blame] | 31 | #include "llvm/Target/TargetRegisterInfo.h" |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 32 | #include "llvm/Target/TargetRegistry.h" |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 33 | #include "llvm/ADT/StringExtras.h" |
Chris Lattner | 6c2f9e1 | 2009-08-19 05:49:37 +0000 | [diff] [blame] | 34 | #include "llvm/Support/ErrorHandling.h" |
| 35 | #include "llvm/Support/FormattedStream.h" |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 36 | using namespace llvm; |
| 37 | |
| 38 | namespace { |
Nick Lewycky | 6726b6d | 2009-10-25 06:33:48 +0000 | [diff] [blame] | 39 | class SPUAsmPrinter : public AsmPrinter { |
Bill Wendling | 57f0db8 | 2009-02-24 08:30:20 +0000 | [diff] [blame] | 40 | public: |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 41 | explicit SPUAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, |
Chris Lattner | 56591ab | 2010-02-02 23:37:42 +0000 | [diff] [blame] | 42 | MCContext &Ctx, MCStreamer &Streamer, |
| 43 | const MCAsmInfo *T) : |
| 44 | AsmPrinter(O, TM, Ctx, Streamer, T) {} |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 45 | |
| 46 | virtual const char *getPassName() const { |
| 47 | return "STI CBEA SPU Assembly Printer"; |
| 48 | } |
| 49 | |
| 50 | SPUTargetMachine &getTM() { |
| 51 | return static_cast<SPUTargetMachine&>(TM); |
| 52 | } |
| 53 | |
| 54 | /// printInstruction - This method is automatically generated by tablegen |
Chris Lattner | 05af261 | 2009-09-13 20:08:00 +0000 | [diff] [blame] | 55 | /// from the instruction set description. |
Chris Lattner | 41aefdc | 2009-08-08 01:32:19 +0000 | [diff] [blame] | 56 | void printInstruction(const MachineInstr *MI); |
Chris Lattner | d95148f | 2009-09-13 20:19:22 +0000 | [diff] [blame] | 57 | static const char *getRegisterName(unsigned RegNo); |
Chris Lattner | 05af261 | 2009-09-13 20:08:00 +0000 | [diff] [blame] | 58 | |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 59 | |
Chris Lattner | 745ec06 | 2010-01-28 01:48:52 +0000 | [diff] [blame] | 60 | void EmitInstruction(const MachineInstr *MI) { |
| 61 | printInstruction(MI); |
Chris Lattner | 8e089a9 | 2010-02-10 00:36:00 +0000 | [diff] [blame] | 62 | OutStreamer.AddBlankLine(); |
Chris Lattner | 745ec06 | 2010-01-28 01:48:52 +0000 | [diff] [blame] | 63 | } |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 64 | void printOp(const MachineOperand &MO); |
| 65 | |
| 66 | /// printRegister - Print register according to target requirements. |
| 67 | /// |
| 68 | void printRegister(const MachineOperand &MO, bool R0AsZero) { |
| 69 | unsigned RegNo = MO.getReg(); |
| 70 | assert(TargetRegisterInfo::isPhysicalRegister(RegNo) && |
| 71 | "Not physreg??"); |
Chris Lattner | 762ccea | 2009-09-13 20:31:40 +0000 | [diff] [blame] | 72 | O << getRegisterName(RegNo); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void printOperand(const MachineInstr *MI, unsigned OpNo) { |
| 76 | const MachineOperand &MO = MI->getOperand(OpNo); |
| 77 | if (MO.isReg()) { |
Chris Lattner | 762ccea | 2009-09-13 20:31:40 +0000 | [diff] [blame] | 78 | O << getRegisterName(MO.getReg()); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 79 | } else if (MO.isImm()) { |
| 80 | O << MO.getImm(); |
| 81 | } else { |
| 82 | printOp(MO); |
| 83 | } |
| 84 | } |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 85 | |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 86 | bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, |
| 87 | unsigned AsmVariant, const char *ExtraCode); |
| 88 | bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, |
| 89 | unsigned AsmVariant, const char *ExtraCode); |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 90 | |
| 91 | |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 92 | void |
| 93 | printS7ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 94 | { |
| 95 | int value = MI->getOperand(OpNo).getImm(); |
| 96 | value = (value << (32 - 7)) >> (32 - 7); |
| 97 | |
| 98 | assert((value >= -(1 << 8) && value <= (1 << 7) - 1) |
| 99 | && "Invalid s7 argument"); |
| 100 | O << value; |
| 101 | } |
| 102 | |
| 103 | void |
| 104 | printU7ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 105 | { |
| 106 | unsigned int value = MI->getOperand(OpNo).getImm(); |
| 107 | assert(value < (1 << 8) && "Invalid u7 argument"); |
| 108 | O << value; |
| 109 | } |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 110 | |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 111 | void |
Scott Michel | f0569be | 2008-12-27 04:51:36 +0000 | [diff] [blame] | 112 | printShufAddr(const MachineInstr *MI, unsigned OpNo) |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 113 | { |
| 114 | char value = MI->getOperand(OpNo).getImm(); |
| 115 | O << (int) value; |
| 116 | O << "("; |
| 117 | printOperand(MI, OpNo+1); |
| 118 | O << ")"; |
| 119 | } |
| 120 | |
| 121 | void |
| 122 | printS16ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 123 | { |
| 124 | O << (short) MI->getOperand(OpNo).getImm(); |
| 125 | } |
| 126 | |
| 127 | void |
| 128 | printU16ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 129 | { |
| 130 | O << (unsigned short)MI->getOperand(OpNo).getImm(); |
| 131 | } |
| 132 | |
| 133 | void |
| 134 | printU32ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 135 | { |
| 136 | O << (unsigned)MI->getOperand(OpNo).getImm(); |
| 137 | } |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 138 | |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 139 | void |
| 140 | printMemRegReg(const MachineInstr *MI, unsigned OpNo) { |
| 141 | // When used as the base register, r0 reads constant zero rather than |
| 142 | // the value contained in the register. For this reason, the darwin |
| 143 | // assembler requires that we print r0 as 0 (no r) when used as the base. |
| 144 | const MachineOperand &MO = MI->getOperand(OpNo); |
Chris Lattner | 762ccea | 2009-09-13 20:31:40 +0000 | [diff] [blame] | 145 | O << getRegisterName(MO.getReg()) << ", "; |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 146 | printOperand(MI, OpNo+1); |
| 147 | } |
| 148 | |
| 149 | void |
| 150 | printU18ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 151 | { |
| 152 | unsigned int value = MI->getOperand(OpNo).getImm(); |
| 153 | assert(value <= (1 << 19) - 1 && "Invalid u18 argument"); |
| 154 | O << value; |
| 155 | } |
| 156 | |
| 157 | void |
| 158 | printS10ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 159 | { |
| 160 | short value = (short) (((int) MI->getOperand(OpNo).getImm() << 16) |
| 161 | >> 16); |
| 162 | assert((value >= -(1 << 9) && value <= (1 << 9) - 1) |
| 163 | && "Invalid s10 argument"); |
| 164 | O << value; |
| 165 | } |
| 166 | |
| 167 | void |
| 168 | printU10ImmOperand(const MachineInstr *MI, unsigned OpNo) |
| 169 | { |
| 170 | short value = (short) (((int) MI->getOperand(OpNo).getImm() << 16) |
| 171 | >> 16); |
| 172 | assert((value <= (1 << 10) - 1) && "Invalid u10 argument"); |
| 173 | O << value; |
| 174 | } |
| 175 | |
| 176 | void |
Scott Michel | f0569be | 2008-12-27 04:51:36 +0000 | [diff] [blame] | 177 | printDFormAddr(const MachineInstr *MI, unsigned OpNo) |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 178 | { |
Chris Lattner | 0f2d995 | 2009-01-21 18:38:18 +0000 | [diff] [blame] | 179 | assert(MI->getOperand(OpNo).isImm() && |
| 180 | "printDFormAddr first operand is not immediate"); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 181 | int64_t value = int64_t(MI->getOperand(OpNo).getImm()); |
Scott Michel | 4379efc | 2008-11-20 05:01:09 +0000 | [diff] [blame] | 182 | int16_t value16 = int16_t(value); |
| 183 | assert((value16 >= -(1 << (9+4)) && value16 <= (1 << (9+4)) - 1) |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 184 | && "Invalid dform s10 offset argument"); |
Scott Michel | f0569be | 2008-12-27 04:51:36 +0000 | [diff] [blame] | 185 | O << (value16 & ~0xf) << "("; |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 186 | printOperand(MI, OpNo+1); |
| 187 | O << ")"; |
| 188 | } |
| 189 | |
| 190 | void |
| 191 | printAddr256K(const MachineInstr *MI, unsigned OpNo) |
| 192 | { |
| 193 | /* Note: operand 1 is an offset or symbol name. */ |
| 194 | if (MI->getOperand(OpNo).isImm()) { |
| 195 | printS16ImmOperand(MI, OpNo); |
| 196 | } else { |
| 197 | printOp(MI->getOperand(OpNo)); |
| 198 | if (MI->getOperand(OpNo+1).isImm()) { |
| 199 | int displ = int(MI->getOperand(OpNo+1).getImm()); |
| 200 | if (displ > 0) |
| 201 | O << "+" << displ; |
| 202 | else if (displ < 0) |
| 203 | O << displ; |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | void printCallOperand(const MachineInstr *MI, unsigned OpNo) { |
| 209 | printOp(MI->getOperand(OpNo)); |
| 210 | } |
| 211 | |
| 212 | void printPCRelativeOperand(const MachineInstr *MI, unsigned OpNo) { |
Scott Michel | aedc637 | 2008-12-10 00:15:19 +0000 | [diff] [blame] | 213 | // Used to generate a ".-<target>", but it turns out that the assembler |
| 214 | // really wants the target. |
| 215 | // |
| 216 | // N.B.: This operand is used for call targets. Branch hints are another |
| 217 | // animal entirely. |
| 218 | printOp(MI->getOperand(OpNo)); |
| 219 | } |
| 220 | |
| 221 | void printHBROperand(const MachineInstr *MI, unsigned OpNo) { |
| 222 | // HBR operands are generated in front of branches, hence, the |
| 223 | // program counter plus the target. |
| 224 | O << ".+"; |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 225 | printOp(MI->getOperand(OpNo)); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | void printSymbolHi(const MachineInstr *MI, unsigned OpNo) { |
| 229 | if (MI->getOperand(OpNo).isImm()) { |
| 230 | printS16ImmOperand(MI, OpNo); |
| 231 | } else { |
| 232 | printOp(MI->getOperand(OpNo)); |
| 233 | O << "@h"; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | void printSymbolLo(const MachineInstr *MI, unsigned OpNo) { |
| 238 | if (MI->getOperand(OpNo).isImm()) { |
| 239 | printS16ImmOperand(MI, OpNo); |
| 240 | } else { |
| 241 | printOp(MI->getOperand(OpNo)); |
| 242 | O << "@l"; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /// Print local store address |
| 247 | void printSymbolLSA(const MachineInstr *MI, unsigned OpNo) { |
| 248 | printOp(MI->getOperand(OpNo)); |
| 249 | } |
| 250 | |
| 251 | void printROTHNeg7Imm(const MachineInstr *MI, unsigned OpNo) { |
| 252 | if (MI->getOperand(OpNo).isImm()) { |
| 253 | int value = (int) MI->getOperand(OpNo).getImm(); |
| 254 | assert((value >= 0 && value < 16) |
| 255 | && "Invalid negated immediate rotate 7-bit argument"); |
| 256 | O << -value; |
| 257 | } else { |
Torok Edwin | c23197a | 2009-07-14 16:55:14 +0000 | [diff] [blame] | 258 | llvm_unreachable("Invalid/non-immediate rotate amount in printRotateNeg7Imm"); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | |
| 262 | void printROTNeg7Imm(const MachineInstr *MI, unsigned OpNo) { |
| 263 | if (MI->getOperand(OpNo).isImm()) { |
| 264 | int value = (int) MI->getOperand(OpNo).getImm(); |
Scott Michel | 104de43 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 265 | assert((value >= 0 && value <= 32) |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 266 | && "Invalid negated immediate rotate 7-bit argument"); |
| 267 | O << -value; |
| 268 | } else { |
Torok Edwin | c23197a | 2009-07-14 16:55:14 +0000 | [diff] [blame] | 269 | llvm_unreachable("Invalid/non-immediate rotate amount in printRotateNeg7Imm"); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 270 | } |
| 271 | } |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 272 | }; |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 273 | } // end of anonymous namespace |
| 274 | |
| 275 | // Include the auto-generated portion of the assembly writer |
| 276 | #include "SPUGenAsmWriter.inc" |
| 277 | |
| 278 | void SPUAsmPrinter::printOp(const MachineOperand &MO) { |
| 279 | switch (MO.getType()) { |
| 280 | case MachineOperand::MO_Immediate: |
Torok Edwin | dac237e | 2009-07-08 20:53:28 +0000 | [diff] [blame] | 281 | llvm_report_error("printOp() does not handle immediate values"); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 282 | return; |
| 283 | |
| 284 | case MachineOperand::MO_MachineBasicBlock: |
Chris Lattner | f71cb01 | 2010-01-26 04:55:51 +0000 | [diff] [blame] | 285 | O << *MO.getMBB()->getSymbol(OutContext); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 286 | return; |
| 287 | case MachineOperand::MO_JumpTableIndex: |
Chris Lattner | 33adcfb | 2009-08-22 21:43:10 +0000 | [diff] [blame] | 288 | O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 289 | << '_' << MO.getIndex(); |
| 290 | return; |
| 291 | case MachineOperand::MO_ConstantPoolIndex: |
Chris Lattner | 33adcfb | 2009-08-22 21:43:10 +0000 | [diff] [blame] | 292 | O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 293 | << '_' << MO.getIndex(); |
| 294 | return; |
| 295 | case MachineOperand::MO_ExternalSymbol: |
| 296 | // Computing the address of an external symbol, not calling it. |
| 297 | if (TM.getRelocationModel() != Reloc::Static) { |
Chris Lattner | 1216441 | 2010-01-16 00:21:18 +0000 | [diff] [blame] | 298 | O << "L" << MAI->getGlobalPrefix() << MO.getSymbolName() |
| 299 | << "$non_lazy_ptr"; |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 300 | return; |
| 301 | } |
Chris Lattner | 10b318b | 2010-01-17 21:43:43 +0000 | [diff] [blame] | 302 | O << *GetExternalSymbolSymbol(MO.getSymbolName()); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 303 | return; |
Chris Lattner | 1216441 | 2010-01-16 00:21:18 +0000 | [diff] [blame] | 304 | case MachineOperand::MO_GlobalAddress: |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 305 | // External or weakly linked global variables need non-lazily-resolved |
| 306 | // stubs |
| 307 | if (TM.getRelocationModel() != Reloc::Static) { |
Chris Lattner | 1216441 | 2010-01-16 00:21:18 +0000 | [diff] [blame] | 308 | GlobalValue *GV = MO.getGlobal(); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 309 | if (((GV->isDeclaration() || GV->hasWeakLinkage() || |
| 310 | GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) { |
Chris Lattner | 10b318b | 2010-01-17 21:43:43 +0000 | [diff] [blame] | 311 | O << *GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 312 | return; |
| 313 | } |
| 314 | } |
Chris Lattner | d62f1b4 | 2010-03-12 21:19:23 +0000 | [diff] [blame] | 315 | O << *Mang->getSymbol(MO.getGlobal()); |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 316 | return; |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 317 | default: |
| 318 | O << "<unknown operand type: " << MO.getType() << ">"; |
| 319 | return; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /// PrintAsmOperand - Print out an operand for an inline asm expression. |
| 324 | /// |
| 325 | bool SPUAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 326 | unsigned AsmVariant, |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 327 | const char *ExtraCode) { |
| 328 | // Does this asm operand have a single letter operand modifier? |
| 329 | if (ExtraCode && ExtraCode[0]) { |
| 330 | if (ExtraCode[1] != 0) return true; // Unknown modifier. |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 331 | |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 332 | switch (ExtraCode[0]) { |
| 333 | default: return true; // Unknown modifier. |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 334 | case 'L': // Write second word of DImode reference. |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 335 | // Verify that this operand has two consecutive registers. |
| 336 | if (!MI->getOperand(OpNo).isReg() || |
| 337 | OpNo+1 == MI->getNumOperands() || |
| 338 | !MI->getOperand(OpNo+1).isReg()) |
| 339 | return true; |
| 340 | ++OpNo; // Return the high-part. |
| 341 | break; |
| 342 | } |
| 343 | } |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 344 | |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 345 | printOperand(MI, OpNo); |
| 346 | return false; |
| 347 | } |
| 348 | |
| 349 | bool SPUAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, |
| 350 | unsigned OpNo, |
Scott Michel | 9de57a9 | 2009-01-26 22:33:37 +0000 | [diff] [blame] | 351 | unsigned AsmVariant, |
Scott Michel | 73655bc | 2008-11-08 18:59:02 +0000 | [diff] [blame] | 352 | const char *ExtraCode) { |
| 353 | if (ExtraCode && ExtraCode[0]) |
| 354 | return true; // Unknown modifier. |
| 355 | printMemRegReg(MI, OpNo); |
| 356 | return false; |
| 357 | } |
| 358 | |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 359 | // Force static initialization. |
| 360 | extern "C" void LLVMInitializeCellSPUAsmPrinter() { |
Chris Lattner | 08acebc | 2010-01-28 01:50:22 +0000 | [diff] [blame] | 361 | RegisterAsmPrinter<SPUAsmPrinter> X(TheCellSPUTarget); |
Daniel Dunbar | 51b198a | 2009-07-15 20:24:03 +0000 | [diff] [blame] | 362 | } |