Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- HexagonAsmPrinter.cpp - Print machine instrs to Hexagon assembly --===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 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 Hexagon assembly language. This printer is |
| 12 | // the output mechanism used by `llc'. |
| 13 | // |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 16 | #include "Hexagon.h" |
Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 17 | #include "HexagonAsmPrinter.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 18 | #include "HexagonMachineFunctionInfo.h" |
Jyotsna Verma | 7503a62 | 2013-02-20 16:13:27 +0000 | [diff] [blame] | 19 | #include "HexagonSubtarget.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 20 | #include "HexagonTargetMachine.h" |
Colin LeMahieu | ff06261 | 2014-11-20 21:56:35 +0000 | [diff] [blame] | 21 | #include "MCTargetDesc/HexagonInstPrinter.h" |
Colin LeMahieu | 1174fea | 2015-02-19 21:10:50 +0000 | [diff] [blame] | 22 | #include "MCTargetDesc/HexagonMCInstrInfo.h" |
Colin LeMahieu | be8c453 | 2015-06-05 16:00:11 +0000 | [diff] [blame] | 23 | #include "MCTargetDesc/HexagonMCShuffler.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/StringExtras.h" |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 25 | #include "llvm/Analysis/ConstantFolding.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 26 | #include "llvm/CodeGen/AsmPrinter.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 27 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 28 | #include "llvm/CodeGen/MachineInstr.h" |
| 29 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/MachineModuleInfo.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 31 | #include "llvm/IR/Constants.h" |
| 32 | #include "llvm/IR/DataLayout.h" |
| 33 | #include "llvm/IR/DerivedTypes.h" |
Rafael Espindola | 894843c | 2014-01-07 21:19:40 +0000 | [diff] [blame] | 34 | #include "llvm/IR/Mangler.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 35 | #include "llvm/IR/Module.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 36 | #include "llvm/MC/MCAsmInfo.h" |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 37 | #include "llvm/MC/MCContext.h" |
| 38 | #include "llvm/MC/MCExpr.h" |
| 39 | #include "llvm/MC/MCInst.h" |
| 40 | #include "llvm/MC/MCSection.h" |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 41 | #include "llvm/MC/MCSectionELF.h" |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 42 | #include "llvm/MC/MCStreamer.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 43 | #include "llvm/MC/MCSymbol.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 44 | #include "llvm/Support/CommandLine.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 45 | #include "llvm/Support/Debug.h" |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 46 | #include "llvm/Support/ELF.h" |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 47 | #include "llvm/Support/Format.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 48 | #include "llvm/Support/MathExtras.h" |
Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 49 | #include "llvm/Support/TargetRegistry.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 50 | #include "llvm/Support/raw_ostream.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 51 | #include "llvm/Target/TargetInstrInfo.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 52 | #include "llvm/Target/TargetLoweringObjectFile.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 53 | #include "llvm/Target/TargetOptions.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 54 | #include "llvm/Target/TargetRegisterInfo.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 55 | |
| 56 | using namespace llvm; |
| 57 | |
Krzysztof Parzyszek | 8d8b229 | 2015-12-02 23:08:29 +0000 | [diff] [blame] | 58 | namespace llvm { |
| 59 | void HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI, |
| 60 | MCInst &MCB, HexagonAsmPrinter &AP); |
| 61 | } |
| 62 | |
Chandler Carruth | 84e68b2 | 2014-04-22 02:41:26 +0000 | [diff] [blame] | 63 | #define DEBUG_TYPE "asm-printer" |
| 64 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 65 | static cl::opt<bool> AlignCalls( |
| 66 | "hexagon-align-calls", cl::Hidden, cl::init(true), |
| 67 | cl::desc("Insert falign after call instruction for Hexagon target")); |
| 68 | |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 69 | // Given a scalar register return its pair. |
| 70 | inline static unsigned getHexagonRegisterPair(unsigned Reg, |
| 71 | const MCRegisterInfo *RI) { |
| 72 | assert(Hexagon::IntRegsRegClass.contains(Reg)); |
| 73 | MCSuperRegIterator SR(Reg, RI, false); |
| 74 | unsigned Pair = *SR; |
| 75 | assert(Hexagon::DoubleRegsRegClass.contains(Pair)); |
| 76 | return Pair; |
| 77 | } |
| 78 | |
David Blaikie | 9459832 | 2015-01-18 20:29:04 +0000 | [diff] [blame] | 79 | HexagonAsmPrinter::HexagonAsmPrinter(TargetMachine &TM, |
| 80 | std::unique_ptr<MCStreamer> Streamer) |
Eric Christopher | 8f276db | 2015-02-03 06:40:22 +0000 | [diff] [blame] | 81 | : AsmPrinter(TM, std::move(Streamer)), Subtarget(nullptr) {} |
David Blaikie | 9459832 | 2015-01-18 20:29:04 +0000 | [diff] [blame] | 82 | |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 83 | void HexagonAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, |
Krzysztof Parzyszek | 29c567a | 2016-07-26 17:31:02 +0000 | [diff] [blame] | 84 | raw_ostream &O) { |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 85 | const MachineOperand &MO = MI->getOperand(OpNo); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 86 | |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 87 | switch (MO.getType()) { |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 88 | default: llvm_unreachable ("<unknown operand type>"); |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 89 | case MachineOperand::MO_Register: |
| 90 | O << HexagonInstPrinter::getRegisterName(MO.getReg()); |
| 91 | return; |
| 92 | case MachineOperand::MO_Immediate: |
| 93 | O << MO.getImm(); |
| 94 | return; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 95 | case MachineOperand::MO_MachineBasicBlock: |
Matt Arsenault | 8b64355 | 2015-06-09 00:31:39 +0000 | [diff] [blame] | 96 | MO.getMBB()->getSymbol()->print(O, MAI); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 97 | return; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 98 | case MachineOperand::MO_ConstantPoolIndex: |
Matt Arsenault | 8b64355 | 2015-06-09 00:31:39 +0000 | [diff] [blame] | 99 | GetCPISymbol(MO.getIndex())->print(O, MAI); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 100 | return; |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 101 | case MachineOperand::MO_GlobalAddress: |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 102 | // Computing the address of a global symbol, not calling it. |
Matt Arsenault | 8b64355 | 2015-06-09 00:31:39 +0000 | [diff] [blame] | 103 | getSymbol(MO.getGlobal())->print(O, MAI); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 104 | printOffset(MO.getOffset(), O); |
| 105 | return; |
| 106 | } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 109 | // |
| 110 | // isBlockOnlyReachableByFallthrough - We need to override this since the |
| 111 | // default AsmPrinter does not print labels for any basic block that |
| 112 | // is only reachable by a fall through. That works for all cases except |
| 113 | // for the case in which the basic block is reachable by a fall through but |
| 114 | // through an indirect from a jump table. In this case, the jump table |
| 115 | // will contain a label not defined by AsmPrinter. |
| 116 | // |
| 117 | bool HexagonAsmPrinter:: |
| 118 | isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const { |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 119 | if (MBB->hasAddressTaken()) |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 120 | return false; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 121 | return AsmPrinter::isBlockOnlyReachableByFallthrough(MBB); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | /// PrintAsmOperand - Print out an operand for an inline asm expression. |
| 126 | /// |
| 127 | bool HexagonAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, |
| 128 | unsigned AsmVariant, |
| 129 | const char *ExtraCode, |
Evandro Menezes | 5cee621 | 2012-04-12 17:55:53 +0000 | [diff] [blame] | 130 | raw_ostream &OS) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 131 | // Does this asm operand have a single letter operand modifier? |
| 132 | if (ExtraCode && ExtraCode[0]) { |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 133 | if (ExtraCode[1] != 0) |
| 134 | return true; // Unknown modifier. |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 135 | |
| 136 | switch (ExtraCode[0]) { |
Jack Carter | 5e69cff | 2012-06-26 13:49:27 +0000 | [diff] [blame] | 137 | default: |
| 138 | // See if this is a generic print operand |
| 139 | return AsmPrinter::PrintAsmOperand(MI, OpNo, AsmVariant, ExtraCode, OS); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 140 | case 'c': // Don't print "$" before a global var name or constant. |
| 141 | // Hexagon never has a prefix. |
| 142 | printOperand(MI, OpNo, OS); |
| 143 | return false; |
Krzysztof Parzyszek | 29c567a | 2016-07-26 17:31:02 +0000 | [diff] [blame] | 144 | case 'L': |
| 145 | case 'H': { // The highest-numbered register of a pair. |
| 146 | const MachineOperand &MO = MI->getOperand(OpNo); |
| 147 | const MachineFunction &MF = *MI->getParent()->getParent(); |
| 148 | const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); |
| 149 | if (!MO.isReg()) |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 150 | return true; |
Krzysztof Parzyszek | 29c567a | 2016-07-26 17:31:02 +0000 | [diff] [blame] | 151 | unsigned RegNumber = MO.getReg(); |
| 152 | // This should be an assert in the frontend. |
| 153 | if (Hexagon::DoubleRegsRegClass.contains(RegNumber)) |
| 154 | RegNumber = TRI->getSubReg(RegNumber, ExtraCode[0] == 'L' ? |
Krzysztof Parzyszek | a540997 | 2016-11-09 16:19:08 +0000 | [diff] [blame] | 155 | Hexagon::isub_lo : |
| 156 | Hexagon::isub_hi); |
Krzysztof Parzyszek | 29c567a | 2016-07-26 17:31:02 +0000 | [diff] [blame] | 157 | OS << HexagonInstPrinter::getRegisterName(RegNumber); |
| 158 | return false; |
| 159 | } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 160 | case 'I': |
| 161 | // Write 'i' if an integer constant, otherwise nothing. Used to print |
| 162 | // addi vs add, etc. |
| 163 | if (MI->getOperand(OpNo).isImm()) |
| 164 | OS << "i"; |
| 165 | return false; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | printOperand(MI, OpNo, OS); |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | bool HexagonAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, |
Krzysztof Parzyszek | 067debe | 2016-08-19 14:12:51 +0000 | [diff] [blame] | 174 | unsigned OpNo, unsigned AsmVariant, |
| 175 | const char *ExtraCode, |
| 176 | raw_ostream &O) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 177 | if (ExtraCode && ExtraCode[0]) |
| 178 | return true; // Unknown modifier. |
| 179 | |
| 180 | const MachineOperand &Base = MI->getOperand(OpNo); |
| 181 | const MachineOperand &Offset = MI->getOperand(OpNo+1); |
| 182 | |
| 183 | if (Base.isReg()) |
| 184 | printOperand(MI, OpNo, O); |
| 185 | else |
Craig Topper | e55c556 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 186 | llvm_unreachable("Unimplemented"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 187 | |
| 188 | if (Offset.isImm()) { |
| 189 | if (Offset.getImm()) |
| 190 | O << " + #" << Offset.getImm(); |
| 191 | } |
| 192 | else |
Craig Topper | e55c556 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 193 | llvm_unreachable("Unimplemented"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 194 | |
| 195 | return false; |
| 196 | } |
| 197 | |
Benjamin Kramer | ab8cc02 | 2016-01-12 14:58:49 +0000 | [diff] [blame] | 198 | static MCSymbol *smallData(AsmPrinter &AP, const MachineInstr &MI, |
| 199 | MCStreamer &OutStreamer, const MCOperand &Imm, |
| 200 | int AlignSize) { |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 201 | MCSymbol *Sym; |
| 202 | int64_t Value; |
| 203 | if (Imm.getExpr()->evaluateAsAbsolute(Value)) { |
| 204 | StringRef sectionPrefix; |
| 205 | std::string ImmString; |
| 206 | StringRef Name; |
| 207 | if (AlignSize == 8) { |
| 208 | Name = ".CONST_0000000000000000"; |
| 209 | sectionPrefix = ".gnu.linkonce.l8"; |
| 210 | ImmString = utohexstr(Value); |
| 211 | } else { |
| 212 | Name = ".CONST_00000000"; |
| 213 | sectionPrefix = ".gnu.linkonce.l4"; |
| 214 | ImmString = utohexstr(static_cast<uint32_t>(Value)); |
| 215 | } |
| 216 | |
| 217 | std::string symbolName = // Yes, leading zeros are kept. |
| 218 | Name.drop_back(ImmString.size()).str() + ImmString; |
| 219 | std::string sectionName = sectionPrefix.str() + symbolName; |
| 220 | |
| 221 | MCSectionELF *Section = OutStreamer.getContext().getELFSection( |
| 222 | sectionName, ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); |
| 223 | OutStreamer.SwitchSection(Section); |
| 224 | |
| 225 | Sym = AP.OutContext.getOrCreateSymbol(Twine(symbolName)); |
| 226 | if (Sym->isUndefined()) { |
| 227 | OutStreamer.EmitLabel(Sym); |
| 228 | OutStreamer.EmitSymbolAttribute(Sym, MCSA_Global); |
| 229 | OutStreamer.EmitIntValue(Value, AlignSize); |
| 230 | OutStreamer.EmitCodeAlignment(AlignSize); |
| 231 | } |
| 232 | } else { |
| 233 | assert(Imm.isExpr() && "Expected expression and found none"); |
| 234 | const MachineOperand &MO = MI.getOperand(1); |
| 235 | assert(MO.isGlobal() || MO.isCPI() || MO.isJTI()); |
| 236 | MCSymbol *MOSymbol = nullptr; |
| 237 | if (MO.isGlobal()) |
| 238 | MOSymbol = AP.getSymbol(MO.getGlobal()); |
| 239 | else if (MO.isCPI()) |
| 240 | MOSymbol = AP.GetCPISymbol(MO.getIndex()); |
| 241 | else if (MO.isJTI()) |
| 242 | MOSymbol = AP.GetJTISymbol(MO.getIndex()); |
| 243 | else |
| 244 | llvm_unreachable("Unknown operand type!"); |
| 245 | |
| 246 | StringRef SymbolName = MOSymbol->getName(); |
| 247 | std::string LitaName = ".CONST_" + SymbolName.str(); |
| 248 | |
| 249 | MCSectionELF *Section = OutStreamer.getContext().getELFSection( |
| 250 | ".lita", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); |
| 251 | |
| 252 | OutStreamer.SwitchSection(Section); |
| 253 | Sym = AP.OutContext.getOrCreateSymbol(Twine(LitaName)); |
| 254 | if (Sym->isUndefined()) { |
| 255 | OutStreamer.EmitLabel(Sym); |
| 256 | OutStreamer.EmitSymbolAttribute(Sym, MCSA_Local); |
| 257 | OutStreamer.EmitValue(Imm.getExpr(), AlignSize); |
| 258 | OutStreamer.EmitCodeAlignment(AlignSize); |
| 259 | } |
| 260 | } |
| 261 | return Sym; |
| 262 | } |
| 263 | |
| 264 | void HexagonAsmPrinter::HexagonProcessInstruction(MCInst &Inst, |
| 265 | const MachineInstr &MI) { |
| 266 | MCInst &MappedInst = static_cast <MCInst &>(Inst); |
| 267 | const MCRegisterInfo *RI = OutStreamer->getContext().getRegisterInfo(); |
| 268 | |
| 269 | switch (Inst.getOpcode()) { |
| 270 | default: return; |
| 271 | |
Colin LeMahieu | ecef1d9 | 2016-02-16 20:38:17 +0000 | [diff] [blame] | 272 | case Hexagon::A2_iconst: { |
| 273 | Inst.setOpcode(Hexagon::A2_addi); |
| 274 | MCOperand Reg = Inst.getOperand(0); |
| 275 | MCOperand S16 = Inst.getOperand(1); |
| 276 | HexagonMCInstrInfo::setMustNotExtend(*S16.getExpr()); |
| 277 | HexagonMCInstrInfo::setS23_2_reloc(*S16.getExpr()); |
| 278 | Inst.clear(); |
| 279 | Inst.addOperand(Reg); |
| 280 | Inst.addOperand(MCOperand::createReg(Hexagon::R0)); |
| 281 | Inst.addOperand(S16); |
| 282 | break; |
| 283 | } |
| 284 | |
Krzysztof Parzyszek | c8d676e | 2017-02-07 17:42:11 +0000 | [diff] [blame] | 285 | case Hexagon::A2_tfrf: { |
| 286 | Inst.setOpcode(Hexagon::A2_paddif); |
| 287 | Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext))); |
| 288 | break; |
| 289 | } |
| 290 | |
| 291 | case Hexagon::A2_tfrt: { |
| 292 | Inst.setOpcode(Hexagon::A2_paddit); |
| 293 | Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext))); |
| 294 | break; |
| 295 | } |
| 296 | |
| 297 | case Hexagon::A2_tfrfnew: { |
| 298 | Inst.setOpcode(Hexagon::A2_paddifnew); |
| 299 | Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext))); |
| 300 | break; |
| 301 | } |
| 302 | |
| 303 | case Hexagon::A2_tfrtnew: { |
| 304 | Inst.setOpcode(Hexagon::A2_padditnew); |
| 305 | Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(0, OutContext))); |
| 306 | break; |
| 307 | } |
| 308 | |
| 309 | case Hexagon::A2_zxtb: { |
| 310 | Inst.setOpcode(Hexagon::A2_andir); |
| 311 | Inst.addOperand(MCOperand::createExpr(MCConstantExpr::create(255, OutContext))); |
| 312 | break; |
| 313 | } |
| 314 | |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 315 | // "$dst = CONST64(#$src1)", |
Krzysztof Parzyszek | a338650 | 2016-08-10 16:46:36 +0000 | [diff] [blame] | 316 | case Hexagon::CONST64: |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 317 | if (!OutStreamer->hasRawTextSupport()) { |
| 318 | const MCOperand &Imm = MappedInst.getOperand(1); |
| 319 | MCSectionSubPair Current = OutStreamer->getCurrentSection(); |
| 320 | |
| 321 | MCSymbol *Sym = smallData(*this, MI, *OutStreamer, Imm, 8); |
| 322 | |
| 323 | OutStreamer->SwitchSection(Current.first, Current.second); |
| 324 | MCInst TmpInst; |
| 325 | MCOperand &Reg = MappedInst.getOperand(0); |
| 326 | TmpInst.setOpcode(Hexagon::L2_loadrdgp); |
| 327 | TmpInst.addOperand(Reg); |
| 328 | TmpInst.addOperand(MCOperand::createExpr( |
| 329 | MCSymbolRefExpr::create(Sym, OutContext))); |
| 330 | MappedInst = TmpInst; |
| 331 | |
| 332 | } |
| 333 | break; |
| 334 | case Hexagon::CONST32: |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 335 | if (!OutStreamer->hasRawTextSupport()) { |
| 336 | MCOperand &Imm = MappedInst.getOperand(1); |
| 337 | MCSectionSubPair Current = OutStreamer->getCurrentSection(); |
| 338 | MCSymbol *Sym = smallData(*this, MI, *OutStreamer, Imm, 4); |
| 339 | OutStreamer->SwitchSection(Current.first, Current.second); |
| 340 | MCInst TmpInst; |
| 341 | MCOperand &Reg = MappedInst.getOperand(0); |
| 342 | TmpInst.setOpcode(Hexagon::L2_loadrigp); |
| 343 | TmpInst.addOperand(Reg); |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame] | 344 | TmpInst.addOperand(MCOperand::createExpr(HexagonMCExpr::create( |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 345 | MCSymbolRefExpr::create(Sym, OutContext), OutContext))); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 346 | MappedInst = TmpInst; |
| 347 | } |
| 348 | break; |
| 349 | |
| 350 | // C2_pxfer_map maps to C2_or instruction. Though, it's possible to use |
| 351 | // C2_or during instruction selection itself but it results |
| 352 | // into suboptimal code. |
| 353 | case Hexagon::C2_pxfer_map: { |
| 354 | MCOperand &Ps = Inst.getOperand(1); |
| 355 | MappedInst.setOpcode(Hexagon::C2_or); |
| 356 | MappedInst.addOperand(Ps); |
| 357 | return; |
| 358 | } |
| 359 | |
| 360 | // Vector reduce complex multiply by scalar, Rt & 1 map to :hi else :lo |
| 361 | // The insn is mapped from the 4 operand to the 3 operand raw form taking |
| 362 | // 3 register pairs. |
| 363 | case Hexagon::M2_vrcmpys_acc_s1: { |
| 364 | MCOperand &Rt = Inst.getOperand(3); |
| 365 | assert (Rt.isReg() && "Expected register and none was found"); |
| 366 | unsigned Reg = RI->getEncodingValue(Rt.getReg()); |
| 367 | if (Reg & 1) |
| 368 | MappedInst.setOpcode(Hexagon::M2_vrcmpys_acc_s1_h); |
| 369 | else |
| 370 | MappedInst.setOpcode(Hexagon::M2_vrcmpys_acc_s1_l); |
| 371 | Rt.setReg(getHexagonRegisterPair(Rt.getReg(), RI)); |
| 372 | return; |
| 373 | } |
| 374 | case Hexagon::M2_vrcmpys_s1: { |
| 375 | MCOperand &Rt = Inst.getOperand(2); |
| 376 | assert (Rt.isReg() && "Expected register and none was found"); |
| 377 | unsigned Reg = RI->getEncodingValue(Rt.getReg()); |
| 378 | if (Reg & 1) |
| 379 | MappedInst.setOpcode(Hexagon::M2_vrcmpys_s1_h); |
| 380 | else |
| 381 | MappedInst.setOpcode(Hexagon::M2_vrcmpys_s1_l); |
| 382 | Rt.setReg(getHexagonRegisterPair(Rt.getReg(), RI)); |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | case Hexagon::M2_vrcmpys_s1rp: { |
| 387 | MCOperand &Rt = Inst.getOperand(2); |
| 388 | assert (Rt.isReg() && "Expected register and none was found"); |
| 389 | unsigned Reg = RI->getEncodingValue(Rt.getReg()); |
| 390 | if (Reg & 1) |
| 391 | MappedInst.setOpcode(Hexagon::M2_vrcmpys_s1rp_h); |
| 392 | else |
| 393 | MappedInst.setOpcode(Hexagon::M2_vrcmpys_s1rp_l); |
| 394 | Rt.setReg(getHexagonRegisterPair(Rt.getReg(), RI)); |
| 395 | return; |
| 396 | } |
| 397 | |
| 398 | case Hexagon::A4_boundscheck: { |
| 399 | MCOperand &Rs = Inst.getOperand(1); |
| 400 | assert (Rs.isReg() && "Expected register and none was found"); |
| 401 | unsigned Reg = RI->getEncodingValue(Rs.getReg()); |
| 402 | if (Reg & 1) // Odd mapped to raw:hi, regpair is rodd:odd-1, like r3:2 |
| 403 | MappedInst.setOpcode(Hexagon::A4_boundscheck_hi); |
| 404 | else // raw:lo |
| 405 | MappedInst.setOpcode(Hexagon::A4_boundscheck_lo); |
| 406 | Rs.setReg(getHexagonRegisterPair(Rs.getReg(), RI)); |
| 407 | return; |
| 408 | } |
Krzysztof Parzyszek | c8d676e | 2017-02-07 17:42:11 +0000 | [diff] [blame] | 409 | case Hexagon::PS_call_nr: |
| 410 | Inst.setOpcode(Hexagon::J2_call); |
| 411 | break; |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 412 | case Hexagon::S5_asrhub_rnd_sat_goodsyntax: { |
| 413 | MCOperand &MO = MappedInst.getOperand(2); |
| 414 | int64_t Imm; |
| 415 | MCExpr const *Expr = MO.getExpr(); |
| 416 | bool Success = Expr->evaluateAsAbsolute(Imm); |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 417 | assert (Success && "Expected immediate and none was found"); |
| 418 | (void)Success; |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 419 | MCInst TmpInst; |
| 420 | if (Imm == 0) { |
| 421 | TmpInst.setOpcode(Hexagon::S2_vsathub); |
| 422 | TmpInst.addOperand(MappedInst.getOperand(0)); |
| 423 | TmpInst.addOperand(MappedInst.getOperand(1)); |
| 424 | MappedInst = TmpInst; |
| 425 | return; |
| 426 | } |
| 427 | TmpInst.setOpcode(Hexagon::S5_asrhub_rnd_sat); |
| 428 | TmpInst.addOperand(MappedInst.getOperand(0)); |
| 429 | TmpInst.addOperand(MappedInst.getOperand(1)); |
| 430 | const MCExpr *One = MCConstantExpr::create(1, OutContext); |
| 431 | const MCExpr *Sub = MCBinaryExpr::createSub(Expr, One, OutContext); |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 432 | TmpInst.addOperand( |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame] | 433 | MCOperand::createExpr(HexagonMCExpr::create(Sub, OutContext))); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 434 | MappedInst = TmpInst; |
| 435 | return; |
| 436 | } |
| 437 | case Hexagon::S5_vasrhrnd_goodsyntax: |
| 438 | case Hexagon::S2_asr_i_p_rnd_goodsyntax: { |
| 439 | MCOperand &MO2 = MappedInst.getOperand(2); |
| 440 | MCExpr const *Expr = MO2.getExpr(); |
| 441 | int64_t Imm; |
| 442 | bool Success = Expr->evaluateAsAbsolute(Imm); |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 443 | assert (Success && "Expected immediate and none was found"); |
| 444 | (void)Success; |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 445 | MCInst TmpInst; |
| 446 | if (Imm == 0) { |
| 447 | TmpInst.setOpcode(Hexagon::A2_combinew); |
| 448 | TmpInst.addOperand(MappedInst.getOperand(0)); |
| 449 | MCOperand &MO1 = MappedInst.getOperand(1); |
Krzysztof Parzyszek | a540997 | 2016-11-09 16:19:08 +0000 | [diff] [blame] | 450 | unsigned High = RI->getSubReg(MO1.getReg(), Hexagon::isub_hi); |
| 451 | unsigned Low = RI->getSubReg(MO1.getReg(), Hexagon::isub_lo); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 452 | // Add a new operand for the second register in the pair. |
| 453 | TmpInst.addOperand(MCOperand::createReg(High)); |
| 454 | TmpInst.addOperand(MCOperand::createReg(Low)); |
| 455 | MappedInst = TmpInst; |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | if (Inst.getOpcode() == Hexagon::S2_asr_i_p_rnd_goodsyntax) |
| 460 | TmpInst.setOpcode(Hexagon::S2_asr_i_p_rnd); |
| 461 | else |
| 462 | TmpInst.setOpcode(Hexagon::S5_vasrhrnd); |
| 463 | TmpInst.addOperand(MappedInst.getOperand(0)); |
| 464 | TmpInst.addOperand(MappedInst.getOperand(1)); |
| 465 | const MCExpr *One = MCConstantExpr::create(1, OutContext); |
| 466 | const MCExpr *Sub = MCBinaryExpr::createSub(Expr, One, OutContext); |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 467 | TmpInst.addOperand( |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame] | 468 | MCOperand::createExpr(HexagonMCExpr::create(Sub, OutContext))); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 469 | MappedInst = TmpInst; |
| 470 | return; |
| 471 | } |
| 472 | // if ("#u5==0") Assembler mapped to: "Rd=Rs"; else Rd=asr(Rs,#u5-1):rnd |
| 473 | case Hexagon::S2_asr_i_r_rnd_goodsyntax: { |
| 474 | MCOperand &MO = Inst.getOperand(2); |
| 475 | MCExpr const *Expr = MO.getExpr(); |
| 476 | int64_t Imm; |
| 477 | bool Success = Expr->evaluateAsAbsolute(Imm); |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 478 | assert (Success && "Expected immediate and none was found"); |
| 479 | (void)Success; |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 480 | MCInst TmpInst; |
| 481 | if (Imm == 0) { |
| 482 | TmpInst.setOpcode(Hexagon::A2_tfr); |
| 483 | TmpInst.addOperand(MappedInst.getOperand(0)); |
| 484 | TmpInst.addOperand(MappedInst.getOperand(1)); |
| 485 | MappedInst = TmpInst; |
| 486 | return; |
| 487 | } |
| 488 | TmpInst.setOpcode(Hexagon::S2_asr_i_r_rnd); |
| 489 | TmpInst.addOperand(MappedInst.getOperand(0)); |
| 490 | TmpInst.addOperand(MappedInst.getOperand(1)); |
| 491 | const MCExpr *One = MCConstantExpr::create(1, OutContext); |
| 492 | const MCExpr *Sub = MCBinaryExpr::createSub(Expr, One, OutContext); |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 493 | TmpInst.addOperand( |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame] | 494 | MCOperand::createExpr(HexagonMCExpr::create(Sub, OutContext))); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 495 | MappedInst = TmpInst; |
| 496 | return; |
| 497 | } |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 498 | |
| 499 | // Translate a "$Rdd = #imm" to "$Rdd = combine(#[-1,0], #imm)" |
| 500 | case Hexagon::A2_tfrpi: { |
| 501 | MCInst TmpInst; |
| 502 | MCOperand &Rdd = MappedInst.getOperand(0); |
| 503 | MCOperand &MO = MappedInst.getOperand(1); |
| 504 | |
| 505 | TmpInst.setOpcode(Hexagon::A2_combineii); |
| 506 | TmpInst.addOperand(Rdd); |
| 507 | int64_t Imm; |
| 508 | bool Success = MO.getExpr()->evaluateAsAbsolute(Imm); |
| 509 | if (Success && Imm < 0) { |
| 510 | const MCExpr *MOne = MCConstantExpr::create(-1, OutContext); |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame] | 511 | TmpInst.addOperand(MCOperand::createExpr(HexagonMCExpr::create(MOne, OutContext))); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 512 | } else { |
| 513 | const MCExpr *Zero = MCConstantExpr::create(0, OutContext); |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame] | 514 | TmpInst.addOperand(MCOperand::createExpr(HexagonMCExpr::create(Zero, OutContext))); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 515 | } |
| 516 | TmpInst.addOperand(MO); |
| 517 | MappedInst = TmpInst; |
| 518 | return; |
| 519 | } |
| 520 | // Translate a "$Rdd = $Rss" to "$Rdd = combine($Rs, $Rt)" |
| 521 | case Hexagon::A2_tfrp: { |
| 522 | MCOperand &MO = MappedInst.getOperand(1); |
Krzysztof Parzyszek | a540997 | 2016-11-09 16:19:08 +0000 | [diff] [blame] | 523 | unsigned High = RI->getSubReg(MO.getReg(), Hexagon::isub_hi); |
| 524 | unsigned Low = RI->getSubReg(MO.getReg(), Hexagon::isub_lo); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 525 | MO.setReg(High); |
| 526 | // Add a new operand for the second register in the pair. |
| 527 | MappedInst.addOperand(MCOperand::createReg(Low)); |
| 528 | MappedInst.setOpcode(Hexagon::A2_combinew); |
| 529 | return; |
| 530 | } |
| 531 | |
| 532 | case Hexagon::A2_tfrpt: |
| 533 | case Hexagon::A2_tfrpf: { |
| 534 | MCOperand &MO = MappedInst.getOperand(2); |
Krzysztof Parzyszek | a540997 | 2016-11-09 16:19:08 +0000 | [diff] [blame] | 535 | unsigned High = RI->getSubReg(MO.getReg(), Hexagon::isub_hi); |
| 536 | unsigned Low = RI->getSubReg(MO.getReg(), Hexagon::isub_lo); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 537 | MO.setReg(High); |
| 538 | // Add a new operand for the second register in the pair. |
| 539 | MappedInst.addOperand(MCOperand::createReg(Low)); |
| 540 | MappedInst.setOpcode((Inst.getOpcode() == Hexagon::A2_tfrpt) |
| 541 | ? Hexagon::C2_ccombinewt |
| 542 | : Hexagon::C2_ccombinewf); |
| 543 | return; |
| 544 | } |
| 545 | case Hexagon::A2_tfrptnew: |
| 546 | case Hexagon::A2_tfrpfnew: { |
| 547 | MCOperand &MO = MappedInst.getOperand(2); |
Krzysztof Parzyszek | a540997 | 2016-11-09 16:19:08 +0000 | [diff] [blame] | 548 | unsigned High = RI->getSubReg(MO.getReg(), Hexagon::isub_hi); |
| 549 | unsigned Low = RI->getSubReg(MO.getReg(), Hexagon::isub_lo); |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 550 | MO.setReg(High); |
| 551 | // Add a new operand for the second register in the pair. |
| 552 | MappedInst.addOperand(MCOperand::createReg(Low)); |
| 553 | MappedInst.setOpcode((Inst.getOpcode() == Hexagon::A2_tfrptnew) |
| 554 | ? Hexagon::C2_ccombinewnewt |
| 555 | : Hexagon::C2_ccombinewnewf); |
| 556 | return; |
| 557 | } |
| 558 | |
| 559 | case Hexagon::M2_mpysmi: { |
| 560 | MCOperand &Imm = MappedInst.getOperand(2); |
| 561 | MCExpr const *Expr = Imm.getExpr(); |
| 562 | int64_t Value; |
| 563 | bool Success = Expr->evaluateAsAbsolute(Value); |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 564 | assert(Success); |
| 565 | (void)Success; |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 566 | if (Value < 0 && Value > -256) { |
| 567 | MappedInst.setOpcode(Hexagon::M2_mpysin); |
Colin LeMahieu | c7b2124 | 2016-02-15 18:47:55 +0000 | [diff] [blame] | 568 | Imm.setExpr(HexagonMCExpr::create( |
Colin LeMahieu | 98c8e07 | 2016-02-15 18:42:07 +0000 | [diff] [blame] | 569 | MCUnaryExpr::createMinus(Expr, OutContext), OutContext)); |
| 570 | } else |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 571 | MappedInst.setOpcode(Hexagon::M2_mpysip); |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | case Hexagon::A2_addsp: { |
| 576 | MCOperand &Rt = Inst.getOperand(1); |
| 577 | assert (Rt.isReg() && "Expected register and none was found"); |
| 578 | unsigned Reg = RI->getEncodingValue(Rt.getReg()); |
| 579 | if (Reg & 1) |
| 580 | MappedInst.setOpcode(Hexagon::A2_addsph); |
| 581 | else |
| 582 | MappedInst.setOpcode(Hexagon::A2_addspl); |
| 583 | Rt.setReg(getHexagonRegisterPair(Rt.getReg(), RI)); |
| 584 | return; |
| 585 | } |
Krzysztof Parzyszek | eabc0d0 | 2016-08-16 17:14:44 +0000 | [diff] [blame] | 586 | case Hexagon::V6_vd0: |
| 587 | case Hexagon::V6_vd0_128B: { |
Krzysztof Parzyszek | 372bd80 | 2015-12-15 17:05:45 +0000 | [diff] [blame] | 588 | MCInst TmpInst; |
| 589 | assert (Inst.getOperand(0).isReg() && |
| 590 | "Expected register and none was found"); |
| 591 | |
| 592 | TmpInst.setOpcode(Hexagon::V6_vxor); |
| 593 | TmpInst.addOperand(Inst.getOperand(0)); |
| 594 | TmpInst.addOperand(Inst.getOperand(0)); |
| 595 | TmpInst.addOperand(Inst.getOperand(0)); |
| 596 | MappedInst = TmpInst; |
| 597 | return; |
| 598 | } |
| 599 | |
| 600 | } |
| 601 | } |
| 602 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 603 | |
| 604 | /// printMachineInstruction -- Print out a single Hexagon MI in Darwin syntax to |
| 605 | /// the current output stream. |
| 606 | /// |
| 607 | void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) { |
Colin LeMahieu | f0af6e5 | 2015-11-13 17:42:46 +0000 | [diff] [blame] | 608 | MCInst MCB = HexagonMCInstrInfo::createBundle(); |
Krzysztof Parzyszek | 8d8b229 | 2015-12-02 23:08:29 +0000 | [diff] [blame] | 609 | const MCInstrInfo &MCII = *Subtarget->getInstrInfo(); |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 610 | |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 611 | if (MI->isBundle()) { |
Colin LeMahieu | 68d967d | 2015-05-29 14:44:13 +0000 | [diff] [blame] | 612 | const MachineBasicBlock* MBB = MI->getParent(); |
Duncan P. N. Exon Smith | c5b668d | 2016-02-22 20:49:58 +0000 | [diff] [blame] | 613 | MachineBasicBlock::const_instr_iterator MII = MI->getIterator(); |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 614 | |
Colin LeMahieu | 7c572b2 | 2015-12-03 16:37:21 +0000 | [diff] [blame] | 615 | for (++MII; MII != MBB->instr_end() && MII->isInsideBundle(); ++MII) |
Krzysztof Parzyszek | d04c9b9 | 2017-03-31 21:03:59 +0000 | [diff] [blame^] | 616 | if (!MII->isDebugValue() && !MII->isImplicitDef()) |
Krzysztof Parzyszek | 8d8b229 | 2015-12-02 23:08:29 +0000 | [diff] [blame] | 617 | HexagonLowerToMC(MCII, &*MII, MCB, *this); |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 618 | } |
Colin LeMahieu | 7c572b2 | 2015-12-03 16:37:21 +0000 | [diff] [blame] | 619 | else |
Krzysztof Parzyszek | 8d8b229 | 2015-12-02 23:08:29 +0000 | [diff] [blame] | 620 | HexagonLowerToMC(MCII, MI, MCB, *this); |
Colin LeMahieu | 7c572b2 | 2015-12-03 16:37:21 +0000 | [diff] [blame] | 621 | |
| 622 | bool Ok = HexagonMCInstrInfo::canonicalizePacket( |
| 623 | MCII, *Subtarget, OutStreamer->getContext(), MCB, nullptr); |
| 624 | assert(Ok); |
| 625 | (void)Ok; |
| 626 | if(HexagonMCInstrInfo::bundleSize(MCB) == 0) |
| 627 | return; |
| 628 | OutStreamer->EmitInstruction(MCB, getSubtargetInfo()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 629 | } |
| 630 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 631 | extern "C" void LLVMInitializeHexagonAsmPrinter() { |
Mehdi Amini | f42454b | 2016-10-09 23:00:34 +0000 | [diff] [blame] | 632 | RegisterAsmPrinter<HexagonAsmPrinter> X(getTheHexagonTarget()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 633 | } |