MachineInstr.cpp (198396) | MachineInstr.cpp (198892) |
---|---|
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" | 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" |
|
16#include "llvm/InlineAsm.h" 17#include "llvm/Value.h" 18#include "llvm/Assembly/Writer.h" 19#include "llvm/CodeGen/MachineFunction.h" 20#include "llvm/CodeGen/MachineMemOperand.h" 21#include "llvm/CodeGen/MachineRegisterInfo.h" 22#include "llvm/CodeGen/PseudoSourceValue.h" 23#include "llvm/Target/TargetMachine.h" --- 151 unchanged lines hidden (view full) --- 175 return getIndex() == Other.getIndex() && getOffset() == Other.getOffset(); 176 case MachineOperand::MO_JumpTableIndex: 177 return getIndex() == Other.getIndex(); 178 case MachineOperand::MO_GlobalAddress: 179 return getGlobal() == Other.getGlobal() && getOffset() == Other.getOffset(); 180 case MachineOperand::MO_ExternalSymbol: 181 return !strcmp(getSymbolName(), Other.getSymbolName()) && 182 getOffset() == Other.getOffset(); | 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(); |
|
183 } 184} 185 186/// print - Print the specified machine operand. 187/// 188void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const { 189 switch (getType()) { 190 case MachineOperand::MO_Register: --- 6 unchanged lines hidden (view full) --- 197 if (const MachineInstr *MI = getParent()) 198 if (const MachineBasicBlock *MBB = MI->getParent()) 199 if (const MachineFunction *MF = MBB->getParent()) 200 TM = &MF->getTarget(); 201 202 if (TM) 203 OS << "%" << TM->getRegisterInfo()->get(getReg()).Name; 204 else | 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 |
205 OS << "%mreg" << getReg(); | 208 OS << "%physreg" << getReg(); |
206 } 207 208 if (getSubReg() != 0) 209 OS << ':' << getSubReg(); 210 211 if (isDef() || isKill() || isDead() || isImplicit() || isUndef() || 212 isEarlyClobber()) { 213 OS << '<'; --- 29 unchanged lines hidden (view full) --- 243 break; 244 case MachineOperand::MO_FPImmediate: 245 if (getFPImm()->getType()->isFloatTy()) 246 OS << getFPImm()->getValueAPF().convertToFloat(); 247 else 248 OS << getFPImm()->getValueAPF().convertToDouble(); 249 break; 250 case MachineOperand::MO_MachineBasicBlock: | 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: |
251 OS << "mbb<" 252 << ((Value*)getMBB()->getBasicBlock())->getName() 253 << "," << (void*)getMBB() << '>'; | 254 OS << "<BB#" << getMBB()->getNumber() << ">"; |
254 break; 255 case MachineOperand::MO_FrameIndex: 256 OS << "<fi#" << getIndex() << '>'; 257 break; 258 case MachineOperand::MO_ConstantPoolIndex: 259 OS << "<cp#" << getIndex(); 260 if (getOffset()) OS << "+" << getOffset(); 261 OS << '>'; --- 6 unchanged lines hidden (view full) --- 268 if (getOffset()) OS << "+" << getOffset(); 269 OS << '>'; 270 break; 271 case MachineOperand::MO_ExternalSymbol: 272 OS << "<es:" << getSymbolName(); 273 if (getOffset()) OS << "+" << getOffset(); 274 OS << '>'; 275 break; | 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; |
|
276 default: 277 llvm_unreachable("Unrecognized operand type"); 278 } 279 280 if (unsigned TF = getTargetFlags()) 281 OS << "[TF=" << TF << ']'; 282} 283 --- 765 unchanged lines hidden (view full) --- 1049 return true; 1050} 1051 1052void MachineInstr::dump() const { 1053 errs() << " " << *this; 1054} 1055 1056void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const { | 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 { |
1057 // Specialize printing if op#0 is definition 1058 unsigned StartOp = 0; 1059 if (getNumOperands() && getOperand(0).isReg() && getOperand(0).isDef()) { 1060 getOperand(0).print(OS, TM); 1061 OS << " = "; 1062 ++StartOp; // Don't print this operand again! | 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); |
1063 } 1064 | 1072 } 1073 |
1074 if (StartOp != 0) 1075 OS << " = "; 1076 1077 // Print the opcode name. |
|
1065 OS << getDesc().getName(); 1066 | 1078 OS << getDesc().getName(); 1079 |
1080 // Print the rest of the operands. |
|
1067 for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) { 1068 if (i != StartOp) 1069 OS << ","; 1070 OS << " "; 1071 getOperand(i).print(OS, TM); 1072 } 1073 | 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; |
|
1074 if (!memoperands_empty()) { | 1089 if (!memoperands_empty()) { |
1075 OS << ", Mem:"; | 1090 if (!HaveSemi) OS << ";"; HaveSemi = true; 1091 1092 OS << " mem:"; |
1076 for (mmo_iterator i = memoperands_begin(), e = memoperands_end(); 1077 i != e; ++i) { 1078 OS << **i; 1079 if (next(i) != e) 1080 OS << " "; 1081 } 1082 } 1083 1084 if (!debugLoc.isUnknown()) { | 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 |
|
1085 const MachineFunction *MF = getParent()->getParent(); 1086 DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); 1087 DICompileUnit CU(DLT.Scope); 1088 if (!CU.isNull()) | 1106 const MachineFunction *MF = getParent()->getParent(); 1107 DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); 1108 DICompileUnit CU(DLT.Scope); 1109 if (!CU.isNull()) |
1089 OS << " [dbg: " 1090 << CU.getDirectory() << '/' << CU.getFilename() << "," 1091 << DLT.Line << "," 1092 << DLT.Col << "]"; | 1110 OS << " dbg:" << CU.getDirectory() << '/' << CU.getFilename() << ":" 1111 << DLT.Line << ":" << DLT.Col; |
1093 } 1094 1095 OS << "\n"; 1096} 1097 1098bool MachineInstr::addRegisterKilled(unsigned IncomingReg, 1099 const TargetRegisterInfo *RegInfo, 1100 bool AddIfNotFound) { --- 112 unchanged lines hidden --- | 1112 } 1113 1114 OS << "\n"; 1115} 1116 1117bool MachineInstr::addRegisterKilled(unsigned IncomingReg, 1118 const TargetRegisterInfo *RegInfo, 1119 bool AddIfNotFound) { --- 112 unchanged lines hidden --- |