1//===-- lib/CodeGen/MachineInstr.cpp --------------------------------------===// 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// Methods common to all machine instructions. 11// 12//===----------------------------------------------------------------------===// 13 14#include "llvm/CodeGen/MachineInstr.h" 15#include "llvm/Constants.h" |
16#include "llvm/Function.h" |
17#include "llvm/InlineAsm.h" 18#include "llvm/Value.h" 19#include "llvm/Assembly/Writer.h" 20#include "llvm/CodeGen/MachineFunction.h" 21#include "llvm/CodeGen/MachineMemOperand.h" 22#include "llvm/CodeGen/MachineRegisterInfo.h" 23#include "llvm/CodeGen/PseudoSourceValue.h" 24#include "llvm/Target/TargetMachine.h" --- 151 unchanged lines hidden (view full) --- 176 return getIndex() == Other.getIndex() && getOffset() == Other.getOffset(); 177 case MachineOperand::MO_JumpTableIndex: 178 return getIndex() == Other.getIndex(); 179 case MachineOperand::MO_GlobalAddress: 180 return getGlobal() == Other.getGlobal() && getOffset() == Other.getOffset(); 181 case MachineOperand::MO_ExternalSymbol: 182 return !strcmp(getSymbolName(), Other.getSymbolName()) && 183 getOffset() == Other.getOffset(); |
184 case MachineOperand::MO_BlockAddress: 185 return getBlockAddress() == Other.getBlockAddress(); |
186 } 187} 188 189/// print - Print the specified machine operand. 190/// 191void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const { 192 switch (getType()) { 193 case MachineOperand::MO_Register: --- 6 unchanged lines hidden (view full) --- 200 if (const MachineInstr *MI = getParent()) 201 if (const MachineBasicBlock *MBB = MI->getParent()) 202 if (const MachineFunction *MF = MBB->getParent()) 203 TM = &MF->getTarget(); 204 205 if (TM) 206 OS << "%" << TM->getRegisterInfo()->get(getReg()).Name; 207 else |
208 OS << "%physreg" << getReg(); |
209 } 210 211 if (getSubReg() != 0) 212 OS << ':' << getSubReg(); 213 214 if (isDef() || isKill() || isDead() || isImplicit() || isUndef() || 215 isEarlyClobber()) { 216 OS << '<'; --- 29 unchanged lines hidden (view full) --- 246 break; 247 case MachineOperand::MO_FPImmediate: 248 if (getFPImm()->getType()->isFloatTy()) 249 OS << getFPImm()->getValueAPF().convertToFloat(); 250 else 251 OS << getFPImm()->getValueAPF().convertToDouble(); 252 break; 253 case MachineOperand::MO_MachineBasicBlock: |
254 OS << "<BB#" << getMBB()->getNumber() << ">"; |
255 break; 256 case MachineOperand::MO_FrameIndex: 257 OS << "<fi#" << getIndex() << '>'; 258 break; 259 case MachineOperand::MO_ConstantPoolIndex: 260 OS << "<cp#" << getIndex(); 261 if (getOffset()) OS << "+" << getOffset(); 262 OS << '>'; --- 6 unchanged lines hidden (view full) --- 269 if (getOffset()) OS << "+" << getOffset(); 270 OS << '>'; 271 break; 272 case MachineOperand::MO_ExternalSymbol: 273 OS << "<es:" << getSymbolName(); 274 if (getOffset()) OS << "+" << getOffset(); 275 OS << '>'; 276 break; |
277 case MachineOperand::MO_BlockAddress: 278 OS << "<"; 279 WriteAsOperand(OS, getBlockAddress(), /*PrintType=*/false); 280 OS << '>'; 281 break; |
282 default: 283 llvm_unreachable("Unrecognized operand type"); 284 } 285 286 if (unsigned TF = getTargetFlags()) 287 OS << "[TF=" << TF << ']'; 288} 289 --- 765 unchanged lines hidden (view full) --- 1055 return true; 1056} 1057 1058void MachineInstr::dump() const { 1059 errs() << " " << *this; 1060} 1061 1062void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const { |
1063 unsigned StartOp = 0, e = getNumOperands(); 1064 1065 // Print explicitly defined operands on the left of an assignment syntax. 1066 for (; StartOp < e && getOperand(StartOp).isReg() && 1067 getOperand(StartOp).isDef() && 1068 !getOperand(StartOp).isImplicit(); 1069 ++StartOp) { 1070 if (StartOp != 0) OS << ", "; 1071 getOperand(StartOp).print(OS, TM); |
1072 } 1073 |
1074 if (StartOp != 0) 1075 OS << " = "; 1076 1077 // Print the opcode name. |
1078 OS << getDesc().getName(); 1079 |
1080 // Print the rest of the operands. |
1081 for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) { 1082 if (i != StartOp) 1083 OS << ","; 1084 OS << " "; 1085 getOperand(i).print(OS, TM); 1086 } 1087 |
1088 bool HaveSemi = false; |
1089 if (!memoperands_empty()) { |
1090 if (!HaveSemi) OS << ";"; HaveSemi = true; 1091 1092 OS << " mem:"; |
1093 for (mmo_iterator i = memoperands_begin(), e = memoperands_end(); 1094 i != e; ++i) { 1095 OS << **i; 1096 if (next(i) != e) 1097 OS << " "; 1098 } 1099 } 1100 1101 if (!debugLoc.isUnknown()) { |
1102 if (!HaveSemi) OS << ";"; HaveSemi = true; 1103 1104 // TODO: print InlinedAtLoc information 1105 |
1106 const MachineFunction *MF = getParent()->getParent(); 1107 DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); 1108 DICompileUnit CU(DLT.Scope); 1109 if (!CU.isNull()) |
1110 OS << " dbg:" << CU.getDirectory() << '/' << CU.getFilename() << ":" 1111 << DLT.Line << ":" << DLT.Col; |
1112 } 1113 1114 OS << "\n"; 1115} 1116 1117bool MachineInstr::addRegisterKilled(unsigned IncomingReg, 1118 const TargetRegisterInfo *RegInfo, 1119 bool AddIfNotFound) { --- 112 unchanged lines hidden --- |