llvm.org GIT mirror llvm / d90183d
Move the getInlineAsmLength virtual method from TAI to TII, where the only real caller (GetFunctionSizeInBytes) uses it. The custom ARM implementation of this is basically reimplementing an assembler poorly for negligible gain. It should be removed IMNSHO, but I'll leave that to ARMish folks to decide. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77877 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
14 changed file(s) with 238 addition(s) and 220 deletion(s). Raw diff Collapse all Expand all
374374 explicit TargetAsmInfo();
375375 virtual ~TargetAsmInfo();
376376
377 /// Measure the specified inline asm to determine an approximation of its
378 /// length.
379 virtual unsigned getInlineAsmLength(const char *Str) const;
380
381377 /// getSLEB128Size - Compute the number of bytes required for a signed
382378 /// leb128 value.
383379 static unsigned getSLEB128Size(int Value);
413409 bool needsSet() const {
414410 return NeedsSet;
415411 }
412 unsigned getMaxInstLength() const {
413 return MaxInstLength;
414 }
416415 const char *getPCSymbol() const {
417416 return PCSymbol;
418417 }
1818
1919 namespace llvm {
2020
21 class TargetAsmInfo;
2122 class TargetRegisterClass;
2223 class TargetRegisterInfo;
2324 class LiveVariables;
455456 return 0;
456457 }
457458
458 /// GetFunctionSizeInBytes - Returns the size of the specified MachineFunction.
459 /// GetFunctionSizeInBytes - Returns the size of the specified
460 /// MachineFunction.
459461 ///
460462 virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const = 0;
463
464 /// Measure the specified inline asm to determine an approximation of its
465 /// length.
466 virtual unsigned getInlineAsmLength(const char *Str,
467 const TargetAsmInfo &TAI) const;
461468 };
462469
463470 /// TargetInstrInfoImpl - This is the default implementation of
2929 EnableARM3Addr("enable-arm-3-addr-conv", cl::Hidden,
3030 cl::desc("Enable ARM 2-addr to 3-addr conv"));
3131
32 ARMBaseInstrInfo::ARMBaseInstrInfo(const ARMSubtarget &sti)
32 ARMBaseInstrInfo::ARMBaseInstrInfo()
3333 : TargetInstrInfoImpl(ARMInsts, array_lengthof(ARMInsts)) {
3434 }
3535
414414 default: {
415415 // If this machine instr is an inline asm, measure it.
416416 if (MI->getOpcode() == ARM::INLINEASM)
417 return TAI->getInlineAsmLength(MI->getOperand(0).getSymbolName());
417 return getInlineAsmLength(MI->getOperand(0).getSymbolName(), *TAI);
418418 if (MI->isLabel())
419419 return 0;
420420 switch (Opc) {
1919 #include "llvm/Target/TargetInstrInfo.h"
2020
2121 namespace llvm {
22 class ARMSubtarget;
2322
2423 /// ARMII - This namespace holds all of the target specific flags that
2524 /// instruction info tracks.
159158 class ARMBaseInstrInfo : public TargetInstrInfoImpl {
160159 protected:
161160 // Can be only subclassed.
162 explicit ARMBaseInstrInfo(const ARMSubtarget &sti);
161 explicit ARMBaseInstrInfo();
163162 public:
164163 // Return the non-pre/post incrementing version of 'Opc'. Return 0
165164 // if there is not such an opcode.
2525 using namespace llvm;
2626
2727 ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI)
28 : ARMBaseInstrInfo(STI), RI(*this, STI) {
29 }
30
31 unsigned ARMInstrInfo::
32 getUnindexedOpcode(unsigned Opc) const {
28 : RI(*this, STI), Subtarget(STI) {
29 }
30
31 unsigned ARMInstrInfo::getUnindexedOpcode(unsigned Opc) const {
3332 switch (Opc) {
3433 default: break;
3534 case ARM::LDR_PRE:
6160 return 0;
6261 }
6362
64 bool ARMInstrInfo::
65 BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
63 bool ARMInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
6664 if (MBB.empty()) return false;
6765
6866 switch (MBB.back().getOpcode()) {
9997 MI->getOperand(0).setReg(DestReg);
10098 MBB.insert(I, MI);
10199 }
100
101 /// Count the number of comma-separated arguments.
102 /// Do not try to detect errors.
103 static unsigned countArguments(const char* p,
104 const TargetAsmInfo &TAI) {
105 unsigned count = 0;
106 while (*p && isspace(*p) && *p != '\n')
107 p++;
108 count++;
109 while (*p && *p!='\n' &&
110 strncmp(p, TAI.getCommentString(),
111 strlen(TAI.getCommentString())) != 0) {
112 if (*p==',')
113 count++;
114 p++;
115 }
116 return count;
117 }
118
119 /// Count the length of a string enclosed in quote characters.
120 /// Do not try to detect errors.
121 static unsigned countString(const char *p) {
122 unsigned count = 0;
123 while (*p && isspace(*p) && *p!='\n')
124 p++;
125 if (!*p || *p != '\"')
126 return count;
127 while (*++p && *p != '\"')
128 count++;
129 return count;
130 }
131
132 /// ARM-specific version of TargetAsmInfo::getInlineAsmLength.
133 unsigned ARMInstrInfo::getInlineAsmLength(const char *s,
134 const TargetAsmInfo &TAI) const {
135 // Make a lowercase-folded version of s for counting purposes.
136 char *q, *s_copy = (char *)malloc(strlen(s) + 1);
137 strcpy(s_copy, s);
138 for (q=s_copy; *q; q++)
139 *q = tolower(*q);
140 const char *Str = s_copy;
141
142 // Count the number of bytes in the asm.
143 bool atInsnStart = true;
144 bool inTextSection = true;
145 unsigned Length = 0;
146 for (; *Str; ++Str) {
147 if (atInsnStart) {
148 // Skip whitespace
149 while (*Str && isspace(*Str) && *Str != '\n')
150 Str++;
151 // Skip label
152 for (const char* p = Str; *p && !isspace(*p); p++)
153 if (*p == ':') {
154 Str = p+1;
155 while (*Str && isspace(*Str) && *Str != '\n')
156 Str++;
157 break;
158 }
159
160 if (*Str == 0) break;
161
162 // Ignore everything from comment char(s) to EOL
163 if (strncmp(Str, TAI.getCommentString(),
164 strlen(TAI.getCommentString())) == 0)
165 atInsnStart = false;
166 // FIXME do something like the following for non-Darwin
167 else if (*Str == '.' && Subtarget.isTargetDarwin()) {
168 // Directive.
169 atInsnStart = false;
170
171 // Some change the section, but don't generate code.
172 if (strncmp(Str, ".literal4", strlen(".literal4"))==0 ||
173 strncmp(Str, ".literal8", strlen(".literal8"))==0 ||
174 strncmp(Str, ".const", strlen(".const"))==0 ||
175 strncmp(Str, ".constructor", strlen(".constructor"))==0 ||
176 strncmp(Str, ".cstring", strlen(".cstring"))==0 ||
177 strncmp(Str, ".data", strlen(".data"))==0 ||
178 strncmp(Str, ".destructor", strlen(".destructor"))==0 ||
179 strncmp(Str, ".fvmlib_init0", strlen(".fvmlib_init0"))==0 ||
180 strncmp(Str, ".fvmlib_init1", strlen(".fvmlib_init1"))==0 ||
181 strncmp(Str, ".mod_init_func", strlen(".mod_init_func"))==0 ||
182 strncmp(Str, ".mod_term_func", strlen(".mod_term_func"))==0 ||
183 strncmp(Str, ".picsymbol_stub", strlen(".picsymbol_stub"))==0 ||
184 strncmp(Str, ".symbol_stub", strlen(".symbol_stub"))==0 ||
185 strncmp(Str, ".static_data", strlen(".static_data"))==0 ||
186 strncmp(Str, ".section", strlen(".section"))==0 ||
187 strncmp(Str, ".lazy_symbol_pointer", strlen(".lazy_symbol_pointer"))==0 ||
188 strncmp(Str, ".non_lazy_symbol_pointer", strlen(".non_lazy_symbol_pointer"))==0 ||
189 strncmp(Str, ".dyld", strlen(".dyld"))==0 ||
190 strncmp(Str, ".const_data", strlen(".const_data"))==0 ||
191 strncmp(Str, ".objc", strlen(".objc"))==0 || //// many directives
192 strncmp(Str, ".static_const", strlen(".static_const"))==0)
193 inTextSection=false;
194 else if (strncmp(Str, ".text", strlen(".text"))==0)
195 inTextSection = true;
196 // Some can't really be handled without implementing significant pieces
197 // of an assembler. Others require dynamic adjustment of block sizes in
198 // AdjustBBOffsetsAfter; it's a big compile-time speed hit to check every
199 // instruction in there, and none of these are currently used in the kernel.
200 else if (strncmp(Str, ".macro", strlen(".macro"))==0 ||
201 strncmp(Str, ".if", strlen(".if"))==0 ||
202 strncmp(Str, ".align", strlen(".align"))==0 ||
203 strncmp(Str, ".fill", strlen(".fill"))==0 ||
204 strncmp(Str, ".space", strlen(".space"))==0 ||
205 strncmp(Str, ".zerofill", strlen(".zerofill"))==0 ||
206 strncmp(Str, ".p2align", strlen(".p2align"))==0 ||
207 strncmp(Str, ".p2alignw", strlen(".p2alignw"))==0 ||
208 strncmp(Str, ".p2alignl", strlen(".p2alignl"))==0 ||
209 strncmp(Str, ".align32", strlen(".p2align32"))==0 ||
210 strncmp(Str, ".include", strlen(".include"))==0)
211 cerr << "Directive " << Str << " in asm may lead to invalid offsets for" <<
212 " constant pools (the assembler will tell you if this happens).\n";
213 // Some generate code, but this is only interesting in the text section.
214 else if (inTextSection) {
215 if (strncmp(Str, ".long", strlen(".long"))==0)
216 Length += 4*countArguments(Str+strlen(".long"), TAI);
217 else if (strncmp(Str, ".short", strlen(".short"))==0)
218 Length += 2*countArguments(Str+strlen(".short"), TAI);
219 else if (strncmp(Str, ".byte", strlen(".byte"))==0)
220 Length += 1*countArguments(Str+strlen(".byte"), TAI);
221 else if (strncmp(Str, ".single", strlen(".single"))==0)
222 Length += 4*countArguments(Str+strlen(".single"), TAI);
223 else if (strncmp(Str, ".double", strlen(".double"))==0)
224 Length += 8*countArguments(Str+strlen(".double"), TAI);
225 else if (strncmp(Str, ".quad", strlen(".quad"))==0)
226 Length += 16*countArguments(Str+strlen(".quad"), TAI);
227 else if (strncmp(Str, ".ascii", strlen(".ascii"))==0)
228 Length += countString(Str+strlen(".ascii"));
229 else if (strncmp(Str, ".asciz", strlen(".asciz"))==0)
230 Length += countString(Str+strlen(".asciz"))+1;
231 }
232 } else if (inTextSection) {
233 // An instruction
234 atInsnStart = false;
235 if (Subtarget.isThumb()) { // FIXME thumb2
236 // BL and BLX are 4 bytes, all others 2.
237 if (strncmp(Str, "blx", strlen("blx"))==0) {
238 const char* p = Str+3;
239 while (*p && isspace(*p))
240 p++;
241 if (*p == 'r' || *p=='R')
242 Length += 2; // BLX reg
243 else
244 Length += 4; // BLX non-reg
245 } else if (strncmp(Str, "bl", strlen("bl"))==0)
246 Length += 4; // BL
247 else
248 Length += 2; // Thumb anything else
249 }
250 else
251 Length += 4; // ARM
252 }
253 }
254 if (*Str == '\n' || *Str == TAI.getSeparatorChar())
255 atInsnStart = true;
256 }
257 free(s_copy);
258 return Length;
259 }
260
2424
2525 class ARMInstrInfo : public ARMBaseInstrInfo {
2626 ARMRegisterInfo RI;
27 const ARMSubtarget &Subtarget;
2728 public:
2829 explicit ARMInstrInfo(const ARMSubtarget &STI);
2930
4344 void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
4445 unsigned DestReg, unsigned SubIdx,
4546 const MachineInstr *Orig) const;
47
48 virtual unsigned getInlineAsmLength(const char *Str,
49 const TargetAsmInfo &TAI) const;
4650 };
4751
4852 }
8080 SupportsDebugInformation = true;
8181 }
8282
83 /// Count the number of comma-separated arguments.
84 /// Do not try to detect errors.
85 static unsigned countArguments(const char* p,
86 const TargetAsmInfo &TAI) {
87 unsigned count = 0;
88 while (*p && isspace(*p) && *p != '\n')
89 p++;
90 count++;
91 while (*p && *p!='\n' &&
92 strncmp(p, TAI.getCommentString(),
93 strlen(TAI.getCommentString())) != 0) {
94 if (*p==',')
95 count++;
96 p++;
97 }
98 return count;
99 }
100
101 /// Count the length of a string enclosed in quote characters.
102 /// Do not try to detect errors.
103 static unsigned countString(const char *p) {
104 unsigned count = 0;
105 while (*p && isspace(*p) && *p!='\n')
106 p++;
107 if (!*p || *p != '\"')
108 return count;
109 while (*++p && *p != '\"')
110 count++;
111 return count;
112 }
113
114 /// ARM-specific version of TargetAsmInfo::getInlineAsmLength.
115 template
116 unsigned ARMTargetAsmInfo::getInlineAsmLength(const char *s) const {
117 // Make a lowercase-folded version of s for counting purposes.
118 char *q, *s_copy = (char *)malloc(strlen(s) + 1);
119 strcpy(s_copy, s);
120 for (q=s_copy; *q; q++)
121 *q = tolower(*q);
122 const char *Str = s_copy;
123
124 // Count the number of bytes in the asm.
125 bool atInsnStart = true;
126 bool inTextSection = true;
127 unsigned Length = 0;
128 for (; *Str; ++Str) {
129 if (atInsnStart) {
130 // Skip whitespace
131 while (*Str && isspace(*Str) && *Str != '\n')
132 Str++;
133 // Skip label
134 for (const char* p = Str; *p && !isspace(*p); p++)
135 if (*p == ':') {
136 Str = p+1;
137 while (*Str && isspace(*Str) && *Str != '\n')
138 Str++;
139 break;
140 }
141
142 if (*Str == 0) break;
143
144 // Ignore everything from comment char(s) to EOL
145 if (strncmp(Str, BaseTAI::CommentString,
146 strlen(BaseTAI::CommentString)) == 0)
147 atInsnStart = false;
148 // FIXME do something like the following for non-Darwin
149 else if (*Str == '.' && Subtarget->isTargetDarwin()) {
150 // Directive.
151 atInsnStart = false;
152
153 // Some change the section, but don't generate code.
154 if (strncmp(Str, ".literal4", strlen(".literal4"))==0 ||
155 strncmp(Str, ".literal8", strlen(".literal8"))==0 ||
156 strncmp(Str, ".const", strlen(".const"))==0 ||
157 strncmp(Str, ".constructor", strlen(".constructor"))==0 ||
158 strncmp(Str, ".cstring", strlen(".cstring"))==0 ||
159 strncmp(Str, ".data", strlen(".data"))==0 ||
160 strncmp(Str, ".destructor", strlen(".destructor"))==0 ||
161 strncmp(Str, ".fvmlib_init0", strlen(".fvmlib_init0"))==0 ||
162 strncmp(Str, ".fvmlib_init1", strlen(".fvmlib_init1"))==0 ||
163 strncmp(Str, ".mod_init_func", strlen(".mod_init_func"))==0 ||
164 strncmp(Str, ".mod_term_func", strlen(".mod_term_func"))==0 ||
165 strncmp(Str, ".picsymbol_stub", strlen(".picsymbol_stub"))==0 ||
166 strncmp(Str, ".symbol_stub", strlen(".symbol_stub"))==0 ||
167 strncmp(Str, ".static_data", strlen(".static_data"))==0 ||
168 strncmp(Str, ".section", strlen(".section"))==0 ||
169 strncmp(Str, ".lazy_symbol_pointer", strlen(".lazy_symbol_pointer"))==0 ||
170 strncmp(Str, ".non_lazy_symbol_pointer", strlen(".non_lazy_symbol_pointer"))==0 ||
171 strncmp(Str, ".dyld", strlen(".dyld"))==0 ||
172 strncmp(Str, ".const_data", strlen(".const_data"))==0 ||
173 strncmp(Str, ".objc", strlen(".objc"))==0 || //// many directives
174 strncmp(Str, ".static_const", strlen(".static_const"))==0)
175 inTextSection=false;
176 else if (strncmp(Str, ".text", strlen(".text"))==0)
177 inTextSection = true;
178 // Some can't really be handled without implementing significant pieces
179 // of an assembler. Others require dynamic adjustment of block sizes in
180 // AdjustBBOffsetsAfter; it's a big compile-time speed hit to check every
181 // instruction in there, and none of these are currently used in the kernel.
182 else if (strncmp(Str, ".macro", strlen(".macro"))==0 ||
183 strncmp(Str, ".if", strlen(".if"))==0 ||
184 strncmp(Str, ".align", strlen(".align"))==0 ||
185 strncmp(Str, ".fill", strlen(".fill"))==0 ||
186 strncmp(Str, ".space", strlen(".space"))==0 ||
187 strncmp(Str, ".zerofill", strlen(".zerofill"))==0 ||
188 strncmp(Str, ".p2align", strlen(".p2align"))==0 ||
189 strncmp(Str, ".p2alignw", strlen(".p2alignw"))==0 ||
190 strncmp(Str, ".p2alignl", strlen(".p2alignl"))==0 ||
191 strncmp(Str, ".align32", strlen(".p2align32"))==0 ||
192 strncmp(Str, ".include", strlen(".include"))==0)
193 cerr << "Directive " << Str << " in asm may lead to invalid offsets for" <<
194 " constant pools (the assembler will tell you if this happens).\n";
195 // Some generate code, but this is only interesting in the text section.
196 else if (inTextSection) {
197 if (strncmp(Str, ".long", strlen(".long"))==0)
198 Length += 4*countArguments(Str+strlen(".long"), *this);
199 else if (strncmp(Str, ".short", strlen(".short"))==0)
200 Length += 2*countArguments(Str+strlen(".short"), *this);
201 else if (strncmp(Str, ".byte", strlen(".byte"))==0)
202 Length += 1*countArguments(Str+strlen(".byte"), *this);
203 else if (strncmp(Str, ".single", strlen(".single"))==0)
204 Length += 4*countArguments(Str+strlen(".single"), *this);
205 else if (strncmp(Str, ".double", strlen(".double"))==0)
206 Length += 8*countArguments(Str+strlen(".double"), *this);
207 else if (strncmp(Str, ".quad", strlen(".quad"))==0)
208 Length += 16*countArguments(Str+strlen(".quad"), *this);
209 else if (strncmp(Str, ".ascii", strlen(".ascii"))==0)
210 Length += countString(Str+strlen(".ascii"));
211 else if (strncmp(Str, ".asciz", strlen(".asciz"))==0)
212 Length += countString(Str+strlen(".asciz"))+1;
213 }
214 } else if (inTextSection) {
215 // An instruction
216 atInsnStart = false;
217 if (Subtarget->isThumb()) { // FIXME thumb2
218 // BL and BLX are 4 bytes, all others 2.
219 if (strncmp(Str, "blx", strlen("blx"))==0) {
220 const char* p = Str+3;
221 while (*p && isspace(*p))
222 p++;
223 if (*p == 'r' || *p=='R')
224 Length += 2; // BLX reg
225 else
226 Length += 4; // BLX non-reg
227 } else if (strncmp(Str, "bl", strlen("bl"))==0)
228 Length += 4; // BL
229 else
230 Length += 2; // Thumb anything else
231 }
232 else
233 Length += 4; // ARM
234 }
235 }
236 if (*Str == '\n' || *Str == BaseTAI::SeparatorChar)
237 atInsnStart = true;
238 }
239 free(s_copy);
240 return Length;
241 }
242
24383 // Instantiate default implementation.
24484 TEMPLATE_INSTANTIATION(class ARMTargetAsmInfo);
3737 }
3838
3939 const ARMSubtarget *Subtarget;
40
41 virtual unsigned getInlineAsmLength(const char *Str) const;
4240 };
4341
4442 EXTERN_TEMPLATE_INSTANTIATION(class ARMTargetAsmInfo);
2121
2222 using namespace llvm;
2323
24 Thumb1InstrInfo::Thumb1InstrInfo(const ARMSubtarget &STI)
25 : ARMBaseInstrInfo(STI), RI(*this, STI) {
24 Thumb1InstrInfo::Thumb1InstrInfo(const ARMSubtarget &STI) : RI(*this, STI) {
2625 }
2726
2827 unsigned Thumb1InstrInfo::getUnindexedOpcode(unsigned Opc) const {
2222
2323 using namespace llvm;
2424
25 Thumb2InstrInfo::Thumb2InstrInfo(const ARMSubtarget &STI)
26 : ARMBaseInstrInfo(STI), RI(*this, STI) {
25 Thumb2InstrInfo::Thumb2InstrInfo(const ARMSubtarget &STI) : RI(*this, STI) {
2726 }
2827
2928 unsigned Thumb2InstrInfo::getUnindexedOpcode(unsigned Opc) const {
767767 case PPC::INLINEASM: { // Inline Asm: Variable size.
768768 const MachineFunction *MF = MI->getParent()->getParent();
769769 const char *AsmStr = MI->getOperand(0).getSymbolName();
770 return MF->getTarget().getTargetAsmInfo()->getInlineAsmLength(AsmStr);
770 return getInlineAsmLength(AsmStr, *MF->getTarget().getTargetAsmInfo());
771771 }
772772 case PPC::DBG_LABEL:
773773 case PPC::EH_LABEL:
102102 TargetAsmInfo::~TargetAsmInfo() {
103103 }
104104
105 /// Measure the specified inline asm to determine an approximation of its
106 /// length.
107 /// Comments (which run till the next SeparatorChar or newline) do not
108 /// count as an instruction.
109 /// Any other non-whitespace text is considered an instruction, with
110 /// multiple instructions separated by SeparatorChar or newlines.
111 /// Variable-length instructions are not handled here; this function
112 /// may be overloaded in the target code to do that.
113 unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
114 // Count the number of instructions in the asm.
115 bool atInsnStart = true;
116 unsigned Length = 0;
117 for (; *Str; ++Str) {
118 if (*Str == '\n' || *Str == SeparatorChar)
119 atInsnStart = true;
120 if (atInsnStart && !isspace(*Str)) {
121 Length += MaxInstLength;
122 atInsnStart = false;
123 }
124 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
125 atInsnStart = false;
126 }
127
128 return Length;
129 }
130105
131106 unsigned TargetAsmInfo::getULEB128Size(unsigned Value) {
132107 unsigned Size = 0;
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Target/TargetInstrInfo.h"
14 #include "llvm/Target/TargetAsmInfo.h"
1415 #include "llvm/Target/TargetRegisterInfo.h"
1516 #include "llvm/Support/ErrorHandling.h"
1617 using namespace llvm;
18
19 //===----------------------------------------------------------------------===//
20 // TargetOperandInfo
21 //===----------------------------------------------------------------------===//
22
23 /// getRegClass - Get the register class for the operand, handling resolution
24 /// of "symbolic" pointer register classes etc. If this is not a register
25 /// operand, this returns null.
26 const TargetRegisterClass *
27 TargetOperandInfo::getRegClass(const TargetRegisterInfo *TRI) const {
28 if (isLookupPtrRegClass())
29 return TRI->getPointerRegClass(RegClass);
30 return TRI->getRegClass(RegClass);
31 }
32
33 //===----------------------------------------------------------------------===//
34 // TargetInstrInfo
35 //===----------------------------------------------------------------------===//
1736
1837 TargetInstrInfo::TargetInstrInfo(const TargetInstrDesc* Desc,
1938 unsigned numOpcodes)
4362 return !isPredicated(MI);
4463 }
4564
46 /// getRegClass - Get the register class for the operand, handling resolution
47 /// of "symbolic" pointer register classes etc. If this is not a register
48 /// operand, this returns null.
49 const TargetRegisterClass *
50 TargetOperandInfo::getRegClass(const TargetRegisterInfo *TRI) const {
51 if (isLookupPtrRegClass())
52 return TRI->getPointerRegClass(RegClass);
53 return TRI->getRegClass(RegClass);
65
66 /// Measure the specified inline asm to determine an approximation of its
67 /// length.
68 /// Comments (which run till the next SeparatorChar or newline) do not
69 /// count as an instruction.
70 /// Any other non-whitespace text is considered an instruction, with
71 /// multiple instructions separated by SeparatorChar or newlines.
72 /// Variable-length instructions are not handled here; this function
73 /// may be overloaded in the target code to do that.
74 unsigned TargetInstrInfo::getInlineAsmLength(const char *Str,
75 const TargetAsmInfo &TAI) const {
76
77
78 // Count the number of instructions in the asm.
79 bool atInsnStart = true;
80 unsigned Length = 0;
81 for (; *Str; ++Str) {
82 if (*Str == '\n' || *Str == TAI.getSeparatorChar())
83 atInsnStart = true;
84 if (atInsnStart && !isspace(*Str)) {
85 Length += TAI.getMaxInstLength();
86 atInsnStart = false;
87 }
88 if (atInsnStart && strncmp(Str, TAI.getCommentString(),
89 strlen(TAI.getCommentString())) == 0)
90 atInsnStart = false;
91 }
92
93 return Length;
5494 }
55
29782978 break;
29792979 case TargetInstrInfo::INLINEASM: {
29802980 const MachineFunction *MF = MI.getParent()->getParent();
2981 const char *AsmStr = MI.getOperand(0).getSymbolName();
2982 const TargetAsmInfo* AI = MF->getTarget().getTargetAsmInfo();
2983 FinalSize += AI->getInlineAsmLength(AsmStr);
2981 const TargetInstrInfo &TII = *MF->getTarget().getInstrInfo();
2982 FinalSize += TII.getInlineAsmLength(MI.getOperand(0).getSymbolName(),
2983 *MF->getTarget().getTargetAsmInfo());
29842984 break;
29852985 }
29862986 case TargetInstrInfo::DBG_LABEL: