llvm.org GIT mirror llvm / 621cdf0
Get rid of virtual inheritance for ARM TAI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56587 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 11 years ago
3 changed file(s) with 40 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
1616 #include
1717 using namespace llvm;
1818
19 static const char *const arm_asm_table[] = {
19 const char *const llvm::arm_asm_table[] = {
2020 "{r0}", "r0",
2121 "{r1}", "r1",
2222 "{r2}", "r2",
4141 "{cc}", "cc",
4242 0,0};
4343
44 ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
45 AsmTransCBE = arm_asm_table;
46
47 AlignmentIsInBytes = false;
48 Data64bitsDirective = 0;
49 CommentString = "@";
50 ConstantPoolSection = "\t.text\n";
51 COMMDirectiveTakesAlignment = false;
52 InlineAsmStart = "@ InlineAsm Start";
53 InlineAsmEnd = "@ InlineAsm End";
54 LCOMMDirective = "\t.lcomm\t";
55 }
44 TEMPLATE_INSTANTIATION(class ARMTargetAsmInfo);
5645
5746 ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM):
58 ARMTargetAsmInfo(TM), DarwinTargetAsmInfo(TM) {
47 ARMTargetAsmInfo(TM) {
5948 Subtarget = &DTM->getSubtarget();
6049
6150 GlobalPrefix = "_";
10392 }
10493
10594 ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM):
106 ARMTargetAsmInfo(TM), ELFTargetAsmInfo(TM) {
95 ARMTargetAsmInfo(TM) {
10796 Subtarget = &ETM->getSubtarget();
10897
10998 NeedsSet = false;
137126
138127 /// Count the number of comma-separated arguments.
139128 /// Do not try to detect errors.
140 unsigned ARMTargetAsmInfo::countArguments(const char* p) const {
129 template
130 unsigned ARMTargetAsmInfo::countArguments(const char* p) const {
141131 unsigned count = 0;
142132 while (*p && isspace(*p) && *p != '\n')
143133 p++;
144134 count++;
145 while (*p && *p!='\n' &&
146 strncmp(p, CommentString, strlen(CommentString))!=0) {
135 while (*p && *p!='\n' &&
136 strncmp(p, BaseTAI::CommentString,
137 strlen(BaseTAI::CommentString))!=0) {
147138 if (*p==',')
148139 count++;
149140 p++;
153144
154145 /// Count the length of a string enclosed in quote characters.
155146 /// Do not try to detect errors.
156 unsigned ARMTargetAsmInfo::countString(const char* p) const {
147 template
148 unsigned ARMTargetAsmInfo::countString(const char* p) const {
157149 unsigned count = 0;
158150 while (*p && isspace(*p) && *p!='\n')
159151 p++;
165157 }
166158
167159 /// ARM-specific version of TargetAsmInfo::getInlineAsmLength.
168 unsigned ARMTargetAsmInfo::getInlineAsmLength(const char *s) const {
160 template
161 unsigned ARMTargetAsmInfo::getInlineAsmLength(const char *s) const {
169162 // Make a lowercase-folded version of s for counting purposes.
170163 char *q, *s_copy = (char *)malloc(strlen(s) + 1);
171164 strcpy(s_copy, s);
191184 break;
192185 }
193186 // Ignore everything from comment char(s) to EOL
194 if (strncmp(Str, CommentString, strlen(CommentString))==-0)
187 if (strncmp(Str, BaseTAI::CommentString, strlen(BaseTAI::CommentString))==-0)
195188 atInsnStart = false;
196189 // FIXME do something like the following for non-Darwin
197190 else if (*Str == '.' && Subtarget->isTargetDarwin()) {
281274 Length += 4; // ARM
282275 }
283276 }
284 if (*Str == '\n' || *Str == SeparatorChar)
277 if (*Str == '\n' || *Str == BaseTAI::SeparatorChar)
285278 atInsnStart = true;
286279 }
287280 free(s_copy);
1313 #ifndef ARMTARGETASMINFO_H
1414 #define ARMTARGETASMINFO_H
1515
16 #include "ARMTargetMachine.h"
1617 #include "llvm/Target/TargetAsmInfo.h"
1718 #include "llvm/Target/ELFTargetAsmInfo.h"
1819 #include "llvm/Target/DarwinTargetAsmInfo.h"
19
20 #include "ARMSubtarget.h"
20 #include "llvm/Support/Compiler.h"
2121
2222 namespace llvm {
2323
24 // Forward declaration.
25 class ARMTargetMachine;
24 extern const char *const arm_asm_table[];
2625
27 struct ARMTargetAsmInfo : public virtual TargetAsmInfo {
28 explicit ARMTargetAsmInfo(const ARMTargetMachine &TM);
26 template
27 struct ARMTargetAsmInfo : public BaseTAI {
28 explicit ARMTargetAsmInfo(const ARMTargetMachine &TM):
29 BaseTAI(TM) {
30 BaseTAI::AsmTransCBE = arm_asm_table;
31
32 BaseTAI::AlignmentIsInBytes = false;
33 BaseTAI::Data64bitsDirective = 0;
34 BaseTAI::CommentString = "@";
35 BaseTAI::ConstantPoolSection = "\t.text\n";
36 BaseTAI::COMMDirectiveTakesAlignment = false;
37 BaseTAI::InlineAsmStart = "@ InlineAsm Start";
38 BaseTAI::InlineAsmEnd = "@ InlineAsm End";
39 BaseTAI::LCOMMDirective = "\t.lcomm\t";
40 }
2941
3042 const ARMSubtarget *Subtarget;
3143
3446 unsigned countString(const char *p) const;
3547 };
3648
37 struct ARMDarwinTargetAsmInfo : public virtual ARMTargetAsmInfo,
38 public virtual DarwinTargetAsmInfo {
49 typedef ARMTargetAsmInfo ARMGenericTargetAsmInfo;
50
51 EXTERN_TEMPLATE_INSTANTIATION(class ARMTargetAsmInfo);
52
53 struct ARMDarwinTargetAsmInfo : public ARMTargetAsmInfo {
3954 explicit ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM);
4055 };
4156
42 struct ARMELFTargetAsmInfo : public virtual ARMTargetAsmInfo,
43 public virtual ELFTargetAsmInfo {
57 struct ARMELFTargetAsmInfo : public ARMTargetAsmInfo {
4458 explicit ARMELFTargetAsmInfo(const ARMTargetMachine &TM);
4559 };
4660
119119 case ARMSubtarget::isELF:
120120 return new ARMELFTargetAsmInfo(*this);
121121 default:
122 return new ARMTargetAsmInfo(*this);
122 return new ARMGenericTargetAsmInfo(*this);
123123 }
124124 }
125125