Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 1 | //===-- ARMTargetAsmInfo.cpp - ARM asm properties ---------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains the declarations of the ARMTargetAsmInfo properties. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "ARMTargetAsmInfo.h" |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 15 | #include "ARMTargetMachine.h" |
Dale Johannesen | 24fb52d | 2007-04-23 20:04:35 +0000 | [diff] [blame] | 16 | #include <cstring> |
| 17 | #include <cctype> |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 18 | using namespace llvm; |
| 19 | |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 20 | const char *const llvm::arm_asm_table[] = { |
Chris Lattner | a93ca92 | 2009-06-18 23:41:35 +0000 | [diff] [blame^] | 21 | "{r0}", "r0", |
| 22 | "{r1}", "r1", |
| 23 | "{r2}", "r2", |
| 24 | "{r3}", "r3", |
| 25 | "{r4}", "r4", |
| 26 | "{r5}", "r5", |
| 27 | "{r6}", "r6", |
| 28 | "{r7}", "r7", |
| 29 | "{r8}", "r8", |
| 30 | "{r9}", "r9", |
| 31 | "{r10}", "r10", |
| 32 | "{r11}", "r11", |
| 33 | "{r12}", "r12", |
| 34 | "{r13}", "r13", |
| 35 | "{r14}", "r14", |
| 36 | "{lr}", "lr", |
| 37 | "{sp}", "sp", |
| 38 | "{ip}", "ip", |
| 39 | "{fp}", "fp", |
| 40 | "{sl}", "sl", |
| 41 | "{memory}", "memory", |
| 42 | "{cc}", "cc", |
| 43 | 0,0 |
| 44 | }; |
Lauro Ramos Venancio | 61718a6 | 2007-06-08 21:06:23 +0000 | [diff] [blame] | 45 | |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 46 | ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM): |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 47 | ARMTargetAsmInfo<DarwinTargetAsmInfo>(TM) { |
Dan Gohman | 8f09225 | 2008-11-03 18:22:42 +0000 | [diff] [blame] | 48 | Subtarget = &TM.getSubtarget<ARMSubtarget>(); |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 49 | |
| 50 | GlobalPrefix = "_"; |
| 51 | PrivateGlobalPrefix = "L"; |
Dale Johannesen | b2dfb89 | 2008-09-09 01:21:22 +0000 | [diff] [blame] | 52 | LessPrivateGlobalPrefix = "l"; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 53 | StringConstantPrefix = "\1LC"; |
| 54 | BSSSection = 0; // no BSS section |
| 55 | ZeroDirective = "\t.space\t"; |
| 56 | ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill |
| 57 | SetDirective = "\t.set\t"; |
| 58 | WeakRefDirective = "\t.weak_reference\t"; |
Evan Cheng | c3ccc1a | 2008-12-06 02:00:55 +0000 | [diff] [blame] | 59 | WeakDefDirective = "\t.weak_definition "; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 60 | HiddenDirective = "\t.private_extern\t"; |
| 61 | ProtectedDirective = NULL; |
| 62 | JumpTableDataSection = ".const"; |
| 63 | CStringSection = "\t.cstring"; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 64 | HasDotTypeDotSizeDirective = false; |
Rafael Espindola | 952b839 | 2008-12-03 11:01:37 +0000 | [diff] [blame] | 65 | HasSingleParameterDotFile = false; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 66 | NeedsIndirectEncoding = true; |
Chris Lattner | a93ca92 | 2009-06-18 23:41:35 +0000 | [diff] [blame^] | 67 | AllowQuotesInName = true; |
| 68 | |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 69 | if (TM.getRelocationModel() == Reloc::Static) { |
| 70 | StaticCtorsSection = ".constructor"; |
| 71 | StaticDtorsSection = ".destructor"; |
| 72 | } else { |
| 73 | StaticCtorsSection = ".mod_init_func"; |
| 74 | StaticDtorsSection = ".mod_term_func"; |
| 75 | } |
| 76 | |
| 77 | // In non-PIC modes, emit a special label before jump tables so that the |
| 78 | // linker can perform more accurate dead code stripping. |
Evan Cheng | b13bafe | 2009-06-18 20:37:15 +0000 | [diff] [blame] | 79 | // Emit a local label that is preserved until the linker runs. |
| 80 | // We do not check the relocation model here since it can be overridden |
| 81 | // later. |
| 82 | JumpTableSpecialLabelPrefix = "l"; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 83 | |
| 84 | NeedsSet = true; |
| 85 | DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; |
| 86 | DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; |
| 87 | DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; |
| 88 | DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; |
| 89 | DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; |
| 90 | DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; |
| 91 | DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; |
| 92 | DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; |
| 93 | DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; |
| 94 | DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; |
Chris Lattner | b839c3f | 2009-06-18 23:31:37 +0000 | [diff] [blame] | 95 | DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM): |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 99 | ARMTargetAsmInfo<ELFTargetAsmInfo>(TM) { |
Dan Gohman | 8f09225 | 2008-11-03 18:22:42 +0000 | [diff] [blame] | 100 | Subtarget = &TM.getSubtarget<ARMSubtarget>(); |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 101 | |
| 102 | NeedsSet = false; |
| 103 | HasLEB128 = true; |
| 104 | AbsoluteDebugSectionOffsets = true; |
| 105 | CStringSection = ".rodata.str"; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 106 | PrivateGlobalPrefix = ".L"; |
| 107 | WeakRefDirective = "\t.weak\t"; |
| 108 | SetDirective = "\t.set\t"; |
| 109 | DwarfRequiresFrameSection = false; |
| 110 | DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",%progbits"; |
| 111 | DwarfInfoSection = "\t.section\t.debug_info,\"\",%progbits"; |
| 112 | DwarfLineSection = "\t.section\t.debug_line,\"\",%progbits"; |
| 113 | DwarfFrameSection = "\t.section\t.debug_frame,\"\",%progbits"; |
| 114 | DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",%progbits"; |
| 115 | DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",%progbits"; |
| 116 | DwarfStrSection = "\t.section\t.debug_str,\"\",%progbits"; |
| 117 | DwarfLocSection = "\t.section\t.debug_loc,\"\",%progbits"; |
| 118 | DwarfARangesSection = "\t.section\t.debug_aranges,\"\",%progbits"; |
| 119 | DwarfRangesSection = "\t.section\t.debug_ranges,\"\",%progbits"; |
Chris Lattner | b839c3f | 2009-06-18 23:31:37 +0000 | [diff] [blame] | 120 | DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",%progbits"; |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 121 | |
| 122 | if (Subtarget->isAAPCS_ABI()) { |
| 123 | StaticCtorsSection = "\t.section .init_array,\"aw\",%init_array"; |
| 124 | StaticDtorsSection = "\t.section .fini_array,\"aw\",%fini_array"; |
| 125 | } else { |
| 126 | StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits"; |
| 127 | StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits"; |
| 128 | } |
Anton Korobeynikov | 0f3cc65 | 2008-08-07 09:54:23 +0000 | [diff] [blame] | 129 | } |
| 130 | |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 131 | /// Count the number of comma-separated arguments. |
| 132 | /// Do not try to detect errors. |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 133 | template <class BaseTAI> |
| 134 | unsigned ARMTargetAsmInfo<BaseTAI>::countArguments(const char* p) const { |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 135 | unsigned count = 0; |
| 136 | while (*p && isspace(*p) && *p != '\n') |
| 137 | p++; |
| 138 | count++; |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 139 | while (*p && *p!='\n' && |
| 140 | strncmp(p, BaseTAI::CommentString, |
| 141 | strlen(BaseTAI::CommentString))!=0) { |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 142 | if (*p==',') |
| 143 | count++; |
| 144 | p++; |
| 145 | } |
| 146 | return count; |
| 147 | } |
| 148 | |
| 149 | /// Count the length of a string enclosed in quote characters. |
| 150 | /// Do not try to detect errors. |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 151 | template <class BaseTAI> |
| 152 | unsigned ARMTargetAsmInfo<BaseTAI>::countString(const char* p) const { |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 153 | unsigned count = 0; |
| 154 | while (*p && isspace(*p) && *p!='\n') |
| 155 | p++; |
| 156 | if (!*p || *p != '\"') |
| 157 | return count; |
| 158 | while (*++p && *p != '\"') |
| 159 | count++; |
| 160 | return count; |
Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 161 | } |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 162 | |
| 163 | /// ARM-specific version of TargetAsmInfo::getInlineAsmLength. |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 164 | template <class BaseTAI> |
| 165 | unsigned ARMTargetAsmInfo<BaseTAI>::getInlineAsmLength(const char *s) const { |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 166 | // Make a lowercase-folded version of s for counting purposes. |
| 167 | char *q, *s_copy = (char *)malloc(strlen(s) + 1); |
| 168 | strcpy(s_copy, s); |
| 169 | for (q=s_copy; *q; q++) |
| 170 | *q = tolower(*q); |
| 171 | const char *Str = s_copy; |
| 172 | |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 173 | // Count the number of bytes in the asm. |
| 174 | bool atInsnStart = true; |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 175 | bool inTextSection = true; |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 176 | unsigned Length = 0; |
| 177 | for (; *Str; ++Str) { |
| 178 | if (atInsnStart) { |
| 179 | // Skip whitespace |
| 180 | while (*Str && isspace(*Str) && *Str != '\n') |
| 181 | Str++; |
| 182 | // Skip label |
| 183 | for (const char* p = Str; *p && !isspace(*p); p++) |
| 184 | if (*p == ':') { |
| 185 | Str = p+1; |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 186 | while (*Str && isspace(*Str) && *Str != '\n') |
| 187 | Str++; |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 188 | break; |
| 189 | } |
Chris Lattner | eda2ec3 | 2009-03-11 16:14:25 +0000 | [diff] [blame] | 190 | |
| 191 | if (*Str == 0) break; |
| 192 | |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 193 | // Ignore everything from comment char(s) to EOL |
Chris Lattner | eda2ec3 | 2009-03-11 16:14:25 +0000 | [diff] [blame] | 194 | if (strncmp(Str, BaseTAI::CommentString, |
| 195 | strlen(BaseTAI::CommentString)) == 0) |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 196 | atInsnStart = false; |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 197 | // FIXME do something like the following for non-Darwin |
| 198 | else if (*Str == '.' && Subtarget->isTargetDarwin()) { |
| 199 | // Directive. |
| 200 | atInsnStart = false; |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 201 | |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 202 | // Some change the section, but don't generate code. |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 203 | if (strncmp(Str, ".literal4", strlen(".literal4"))==0 || |
| 204 | strncmp(Str, ".literal8", strlen(".literal8"))==0 || |
| 205 | strncmp(Str, ".const", strlen(".const"))==0 || |
| 206 | strncmp(Str, ".constructor", strlen(".constructor"))==0 || |
| 207 | strncmp(Str, ".cstring", strlen(".cstring"))==0 || |
| 208 | strncmp(Str, ".data", strlen(".data"))==0 || |
| 209 | strncmp(Str, ".destructor", strlen(".destructor"))==0 || |
| 210 | strncmp(Str, ".fvmlib_init0", strlen(".fvmlib_init0"))==0 || |
| 211 | strncmp(Str, ".fvmlib_init1", strlen(".fvmlib_init1"))==0 || |
| 212 | strncmp(Str, ".mod_init_func", strlen(".mod_init_func"))==0 || |
| 213 | strncmp(Str, ".mod_term_func", strlen(".mod_term_func"))==0 || |
| 214 | strncmp(Str, ".picsymbol_stub", strlen(".picsymbol_stub"))==0 || |
| 215 | strncmp(Str, ".symbol_stub", strlen(".symbol_stub"))==0 || |
| 216 | strncmp(Str, ".static_data", strlen(".static_data"))==0 || |
| 217 | strncmp(Str, ".section", strlen(".section"))==0 || |
| 218 | strncmp(Str, ".lazy_symbol_pointer", strlen(".lazy_symbol_pointer"))==0 || |
| 219 | strncmp(Str, ".non_lazy_symbol_pointer", strlen(".non_lazy_symbol_pointer"))==0 || |
| 220 | strncmp(Str, ".dyld", strlen(".dyld"))==0 || |
| 221 | strncmp(Str, ".const_data", strlen(".const_data"))==0 || |
| 222 | strncmp(Str, ".objc", strlen(".objc"))==0 || //// many directives |
| 223 | strncmp(Str, ".static_const", strlen(".static_const"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 224 | inTextSection=false; |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 225 | else if (strncmp(Str, ".text", strlen(".text"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 226 | inTextSection = true; |
| 227 | // Some can't really be handled without implementing significant pieces |
| 228 | // of an assembler. Others require dynamic adjustment of block sizes in |
| 229 | // AdjustBBOffsetsAfter; it's a big compile-time speed hit to check every |
| 230 | // instruction in there, and none of these are currently used in the kernel. |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 231 | else if (strncmp(Str, ".macro", strlen(".macro"))==0 || |
| 232 | strncmp(Str, ".if", strlen(".if"))==0 || |
| 233 | strncmp(Str, ".align", strlen(".align"))==0 || |
| 234 | strncmp(Str, ".fill", strlen(".fill"))==0 || |
| 235 | strncmp(Str, ".space", strlen(".space"))==0 || |
| 236 | strncmp(Str, ".zerofill", strlen(".zerofill"))==0 || |
| 237 | strncmp(Str, ".p2align", strlen(".p2align"))==0 || |
| 238 | strncmp(Str, ".p2alignw", strlen(".p2alignw"))==0 || |
| 239 | strncmp(Str, ".p2alignl", strlen(".p2alignl"))==0 || |
| 240 | strncmp(Str, ".align32", strlen(".p2align32"))==0 || |
| 241 | strncmp(Str, ".include", strlen(".include"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 242 | cerr << "Directive " << Str << " in asm may lead to invalid offsets for" << |
| 243 | " constant pools (the assembler will tell you if this happens).\n"; |
| 244 | // Some generate code, but this is only interesting in the text section. |
| 245 | else if (inTextSection) { |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 246 | if (strncmp(Str, ".long", strlen(".long"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 247 | Length += 4*countArguments(Str+strlen(".long")); |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 248 | else if (strncmp(Str, ".short", strlen(".short"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 249 | Length += 2*countArguments(Str+strlen(".short")); |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 250 | else if (strncmp(Str, ".byte", strlen(".byte"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 251 | Length += 1*countArguments(Str+strlen(".byte")); |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 252 | else if (strncmp(Str, ".single", strlen(".single"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 253 | Length += 4*countArguments(Str+strlen(".single")); |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 254 | else if (strncmp(Str, ".double", strlen(".double"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 255 | Length += 8*countArguments(Str+strlen(".double")); |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 256 | else if (strncmp(Str, ".quad", strlen(".quad"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 257 | Length += 16*countArguments(Str+strlen(".quad")); |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 258 | else if (strncmp(Str, ".ascii", strlen(".ascii"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 259 | Length += countString(Str+strlen(".ascii")); |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 260 | else if (strncmp(Str, ".asciz", strlen(".asciz"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 261 | Length += countString(Str+strlen(".asciz"))+1; |
| 262 | } |
| 263 | } else if (inTextSection) { |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 264 | // An instruction |
| 265 | atInsnStart = false; |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 266 | if (Subtarget->isThumb()) { |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 267 | // BL and BLX <non-reg> are 4 bytes, all others 2. |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 268 | if (strncmp(Str, "blx", strlen("blx"))==0) { |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 269 | const char* p = Str+3; |
| 270 | while (*p && isspace(*p)) |
| 271 | p++; |
| 272 | if (*p == 'r' || *p=='R') |
| 273 | Length += 2; // BLX reg |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 274 | else |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 275 | Length += 4; // BLX non-reg |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 276 | } else if (strncmp(Str, "bl", strlen("bl"))==0) |
Dale Johannesen | 67cf561 | 2007-05-02 01:02:40 +0000 | [diff] [blame] | 277 | Length += 4; // BL |
| 278 | else |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 279 | Length += 2; // Thumb anything else |
| 280 | } |
| 281 | else |
| 282 | Length += 4; // ARM |
| 283 | } |
| 284 | } |
Anton Korobeynikov | 32b952a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 285 | if (*Str == '\n' || *Str == BaseTAI::SeparatorChar) |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 286 | atInsnStart = true; |
| 287 | } |
Dale Johannesen | ca4571e | 2007-10-25 21:54:43 +0000 | [diff] [blame] | 288 | free(s_copy); |
Dale Johannesen | 8650199 | 2007-04-29 19:17:45 +0000 | [diff] [blame] | 289 | return Length; |
| 290 | } |
Anton Korobeynikov | 6381a13 | 2008-10-05 08:53:29 +0000 | [diff] [blame] | 291 | |
| 292 | // Instantiate default implementation. |
| 293 | TEMPLATE_INSTANTIATION(class ARMTargetAsmInfo<TargetAsmInfo>); |