blob: d56f618d1ea15c29c0faa87bde4a3a1e0b5f1c6f [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- ARMAsmPrinter.cpp - ARM LLVM assembly writer ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains a printer that converts from our internal representation
11// of machine-dependent LLVM code to GAS-format ARM assembly language.
12//
13//===----------------------------------------------------------------------===//
14
15#define DEBUG_TYPE "asm-printer"
16#include "ARM.h"
17#include "ARMTargetMachine.h"
18#include "ARMAddressingModes.h"
19#include "ARMConstantPoolValue.h"
20#include "ARMMachineFunctionInfo.h"
21#include "llvm/Constants.h"
22#include "llvm/Module.h"
23#include "llvm/CodeGen/AsmPrinter.h"
24#include "llvm/CodeGen/DwarfWriter.h"
25#include "llvm/CodeGen/MachineModuleInfo.h"
26#include "llvm/CodeGen/MachineFunctionPass.h"
27#include "llvm/CodeGen/MachineJumpTableInfo.h"
28#include "llvm/Target/TargetAsmInfo.h"
29#include "llvm/Target/TargetData.h"
30#include "llvm/Target/TargetMachine.h"
31#include "llvm/Target/TargetOptions.h"
32#include "llvm/ADT/Statistic.h"
33#include "llvm/ADT/StringExtras.h"
34#include "llvm/Support/Compiler.h"
35#include "llvm/Support/Mangler.h"
36#include "llvm/Support/MathExtras.h"
37#include <cctype>
38using namespace llvm;
39
40STATISTIC(EmittedInsts, "Number of machine instrs printed");
41
42namespace {
43 struct VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter {
44 ARMAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
45 : AsmPrinter(O, TM, T), DW(O, this, T), AFI(NULL), InCPMode(false) {
46 Subtarget = &TM.getSubtarget<ARMSubtarget>();
47 }
48
49 DwarfWriter DW;
50
51 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
52 /// make the right decision when printing asm code for different targets.
53 const ARMSubtarget *Subtarget;
54
55 /// AFI - Keep a pointer to ARMFunctionInfo for the current
56 /// MachineFunction
57 ARMFunctionInfo *AFI;
58
59 /// We name each basic block in a Function with a unique number, so
60 /// that we can consistently refer to them later. This is cleared
61 /// at the beginning of each call to runOnMachineFunction().
62 ///
63 typedef std::map<const Value *, unsigned> ValueMapTy;
64 ValueMapTy NumberForBB;
65
66 /// Keeps the set of GlobalValues that require non-lazy-pointers for
67 /// indirect access.
68 std::set<std::string> GVNonLazyPtrs;
69
70 /// Keeps the set of external function GlobalAddresses that the asm
71 /// printer should generate stubs for.
72 std::set<std::string> FnStubs;
73
74 /// True if asm printer is printing a series of CONSTPOOL_ENTRY.
75 bool InCPMode;
76
77 virtual const char *getPassName() const {
78 return "ARM Assembly Printer";
79 }
80
81 void printOperand(const MachineInstr *MI, int opNum,
82 const char *Modifier = 0);
83 void printSOImmOperand(const MachineInstr *MI, int opNum);
84 void printSOImm2PartOperand(const MachineInstr *MI, int opNum);
85 void printSORegOperand(const MachineInstr *MI, int opNum);
86 void printAddrMode2Operand(const MachineInstr *MI, int OpNo);
87 void printAddrMode2OffsetOperand(const MachineInstr *MI, int OpNo);
88 void printAddrMode3Operand(const MachineInstr *MI, int OpNo);
89 void printAddrMode3OffsetOperand(const MachineInstr *MI, int OpNo);
90 void printAddrMode4Operand(const MachineInstr *MI, int OpNo,
91 const char *Modifier = 0);
92 void printAddrMode5Operand(const MachineInstr *MI, int OpNo,
93 const char *Modifier = 0);
94 void printAddrModePCOperand(const MachineInstr *MI, int OpNo,
95 const char *Modifier = 0);
96 void printThumbAddrModeRROperand(const MachineInstr *MI, int OpNo);
97 void printThumbAddrModeRI5Operand(const MachineInstr *MI, int OpNo,
98 unsigned Scale);
99 void printThumbAddrModeS1Operand(const MachineInstr *MI, int OpNo);
100 void printThumbAddrModeS2Operand(const MachineInstr *MI, int OpNo);
101 void printThumbAddrModeS4Operand(const MachineInstr *MI, int OpNo);
102 void printThumbAddrModeSPOperand(const MachineInstr *MI, int OpNo);
103 void printPredicateOperand(const MachineInstr *MI, int opNum);
104 void printSBitModifierOperand(const MachineInstr *MI, int opNum);
105 void printPCLabel(const MachineInstr *MI, int opNum);
106 void printRegisterList(const MachineInstr *MI, int opNum);
107 void printCPInstOperand(const MachineInstr *MI, int opNum,
108 const char *Modifier);
109 void printJTBlockOperand(const MachineInstr *MI, int opNum);
110
111 virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
112 unsigned AsmVariant, const char *ExtraCode);
113
114 bool printInstruction(const MachineInstr *MI); // autogenerated.
115 void printMachineInstruction(const MachineInstr *MI);
116 bool runOnMachineFunction(MachineFunction &F);
117 bool doInitialization(Module &M);
118 bool doFinalization(Module &M);
119
120 virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
121 printDataDirective(MCPV->getType());
122
123 ARMConstantPoolValue *ACPV = (ARMConstantPoolValue*)MCPV;
124 GlobalValue *GV = ACPV->getGV();
125 std::string Name = GV ? Mang->getValueName(GV) : TAI->getGlobalPrefix();
126 if (!GV)
127 Name += ACPV->getSymbol();
128 if (ACPV->isNonLazyPointer()) {
129 GVNonLazyPtrs.insert(Name);
130 O << TAI->getPrivateGlobalPrefix() << Name << "$non_lazy_ptr";
131 } else if (ACPV->isStub()) {
132 FnStubs.insert(Name);
133 O << TAI->getPrivateGlobalPrefix() << Name << "$stub";
134 } else
135 O << Name;
136 if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")";
137 if (ACPV->getPCAdjustment() != 0) {
138 O << "-(" << TAI->getPrivateGlobalPrefix() << "PC"
139 << utostr(ACPV->getLabelId())
140 << "+" << (unsigned)ACPV->getPCAdjustment();
141 if (ACPV->mustAddCurrentAddress())
142 O << "-.";
143 O << ")";
144 }
145 O << "\n";
146
147 // If the constant pool value is a extern weak symbol, remember to emit
148 // the weak reference.
149 if (GV && GV->hasExternalWeakLinkage())
150 ExtWeakSymbols.insert(GV);
151 }
152
153 void getAnalysisUsage(AnalysisUsage &AU) const {
Gordon Henriksen76e4b612007-09-30 13:39:29 +0000154 AsmPrinter::getAnalysisUsage(AU);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000155 AU.setPreservesAll();
156 AU.addRequired<MachineModuleInfo>();
157 }
158 };
159} // end of anonymous namespace
160
161#include "ARMGenAsmWriter.inc"
162
163/// createARMCodePrinterPass - Returns a pass that prints the ARM
164/// assembly code for a MachineFunction to the given output stream,
165/// using the given target machine description. This should work
166/// regardless of whether the function is in SSA form.
167///
168FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o,
169 ARMTargetMachine &tm) {
170 return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo());
171}
172
173/// runOnMachineFunction - This uses the printInstruction()
174/// method to print assembly for each instruction.
175///
176bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
177 AFI = MF.getInfo<ARMFunctionInfo>();
178
179 DW.SetModuleInfo(&getAnalysis<MachineModuleInfo>());
180
181 SetupMachineFunction(MF);
182 O << "\n";
183
184 // NOTE: we don't print out constant pools here, they are handled as
185 // instructions.
186
187 O << "\n";
188 // Print out labels for the function.
189 const Function *F = MF.getFunction();
190 switch (F->getLinkage()) {
191 default: assert(0 && "Unknown linkage type!");
192 case Function::InternalLinkage:
193 SwitchToTextSection("\t.text", F);
194 break;
195 case Function::ExternalLinkage:
196 SwitchToTextSection("\t.text", F);
197 O << "\t.globl\t" << CurrentFnName << "\n";
198 break;
199 case Function::WeakLinkage:
200 case Function::LinkOnceLinkage:
201 if (Subtarget->isTargetDarwin()) {
202 SwitchToTextSection(
203 ".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F);
204 O << "\t.globl\t" << CurrentFnName << "\n";
205 O << "\t.weak_definition\t" << CurrentFnName << "\n";
206 } else {
207 O << TAI->getWeakRefDirective() << CurrentFnName << "\n";
208 }
209 break;
210 }
211
212 const char *VisibilityDirective = NULL;
213 if (F->hasHiddenVisibility())
214 VisibilityDirective = TAI->getHiddenDirective();
215 else if (F->hasProtectedVisibility())
216 VisibilityDirective = TAI->getProtectedDirective();
217
218 if (VisibilityDirective)
219 O << VisibilityDirective << CurrentFnName << "\n";
220
221 if (AFI->isThumbFunction()) {
222 EmitAlignment(1, F, AFI->getAlign());
223 O << "\t.code\t16\n";
224 O << "\t.thumb_func";
225 if (Subtarget->isTargetDarwin())
226 O << "\t" << CurrentFnName;
227 O << "\n";
228 InCPMode = false;
229 } else
230 EmitAlignment(2, F);
231
232 O << CurrentFnName << ":\n";
233 // Emit pre-function debug information.
234 DW.BeginFunction(&MF);
235
Bill Wendling43a78162008-01-28 09:15:03 +0000236 if (Subtarget->isTargetDarwin()) {
237 // If the function is empty, then we need to emit *something*. Otherwise,
238 // the function's label might be associated with something that it wasn't
239 // meant to be associated with. We emit a noop in this situation.
240 MachineFunction::iterator I = MF.begin();
241
242 if (++I == MF.end() && MF.front().empty())
243 O << "\tnop\n";
244 }
245
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246 // Print out code for the function.
247 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
248 I != E; ++I) {
249 // Print a label for the basic block.
250 if (I != MF.begin()) {
251 printBasicBlockLabel(I, true);
252 O << '\n';
253 }
254 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
255 II != E; ++II) {
256 // Print the assembly for the instruction.
257 printMachineInstruction(II);
258 }
259 }
260
261 if (TAI->hasDotTypeDotSizeDirective())
262 O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
263
264 // Emit post-function debug information.
265 DW.EndFunction();
266
267 return false;
268}
269
270void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
271 const char *Modifier) {
272 const MachineOperand &MO = MI->getOperand(opNum);
273 switch (MO.getType()) {
274 case MachineOperand::MO_Register:
275 if (MRegisterInfo::isPhysicalRegister(MO.getReg()))
276 O << TM.getRegisterInfo()->get(MO.getReg()).Name;
277 else
278 assert(0 && "not implemented");
279 break;
280 case MachineOperand::MO_Immediate: {
281 if (!Modifier || strcmp(Modifier, "no_hash") != 0)
282 O << "#";
283
Chris Lattnera96056a2007-12-30 20:49:49 +0000284 O << (int)MO.getImm();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285 break;
286 }
287 case MachineOperand::MO_MachineBasicBlock:
Chris Lattner6017d482007-12-30 23:10:15 +0000288 printBasicBlockLabel(MO.getMBB());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289 return;
290 case MachineOperand::MO_GlobalAddress: {
291 bool isCallOp = Modifier && !strcmp(Modifier, "call");
292 GlobalValue *GV = MO.getGlobal();
293 std::string Name = Mang->getValueName(GV);
294 bool isExt = (GV->isDeclaration() || GV->hasWeakLinkage() ||
295 GV->hasLinkOnceLinkage());
296 if (isExt && isCallOp && Subtarget->isTargetDarwin() &&
297 TM.getRelocationModel() != Reloc::Static) {
298 O << TAI->getPrivateGlobalPrefix() << Name << "$stub";
299 FnStubs.insert(Name);
300 } else
301 O << Name;
302
303 if (MO.getOffset() > 0)
304 O << '+' << MO.getOffset();
305 else if (MO.getOffset() < 0)
306 O << MO.getOffset();
307
308 if (isCallOp && Subtarget->isTargetELF() &&
309 TM.getRelocationModel() == Reloc::PIC_)
310 O << "(PLT)";
311 if (GV->hasExternalWeakLinkage())
312 ExtWeakSymbols.insert(GV);
313 break;
314 }
315 case MachineOperand::MO_ExternalSymbol: {
316 bool isCallOp = Modifier && !strcmp(Modifier, "call");
317 std::string Name(TAI->getGlobalPrefix());
318 Name += MO.getSymbolName();
319 if (isCallOp && Subtarget->isTargetDarwin() &&
320 TM.getRelocationModel() != Reloc::Static) {
321 O << TAI->getPrivateGlobalPrefix() << Name << "$stub";
322 FnStubs.insert(Name);
323 } else
324 O << Name;
325 if (isCallOp && Subtarget->isTargetELF() &&
326 TM.getRelocationModel() == Reloc::PIC_)
327 O << "(PLT)";
328 break;
329 }
330 case MachineOperand::MO_ConstantPoolIndex:
Evan Cheng477013c2007-10-14 05:57:21 +0000331 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
Chris Lattner6017d482007-12-30 23:10:15 +0000332 << '_' << MO.getIndex();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 break;
334 case MachineOperand::MO_JumpTableIndex:
Evan Cheng477013c2007-10-14 05:57:21 +0000335 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
Chris Lattner6017d482007-12-30 23:10:15 +0000336 << '_' << MO.getIndex();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 break;
338 default:
339 O << "<unknown operand type>"; abort (); break;
340 }
341}
342
343static void printSOImm(std::ostream &O, int64_t V, const TargetAsmInfo *TAI) {
344 assert(V < (1 << 12) && "Not a valid so_imm value!");
345 unsigned Imm = ARM_AM::getSOImmValImm(V);
346 unsigned Rot = ARM_AM::getSOImmValRot(V);
347
348 // Print low-level immediate formation info, per
349 // A5.1.3: "Data-processing operands - Immediate".
350 if (Rot) {
351 O << "#" << Imm << ", " << Rot;
352 // Pretty printed version.
353 O << ' ' << TAI->getCommentString() << ' ' << (int)ARM_AM::rotr32(Imm, Rot);
354 } else {
355 O << "#" << Imm;
356 }
357}
358
359/// printSOImmOperand - SOImm is 4-bit rotate amount in bits 8-11 with 8-bit
360/// immediate in bits 0-7.
361void ARMAsmPrinter::printSOImmOperand(const MachineInstr *MI, int OpNum) {
362 const MachineOperand &MO = MI->getOperand(OpNum);
363 assert(MO.isImmediate() && "Not a valid so_imm value!");
Chris Lattnera96056a2007-12-30 20:49:49 +0000364 printSOImm(O, MO.getImm(), TAI);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365}
366
367/// printSOImm2PartOperand - SOImm is broken into two pieces using a mov
368/// followed by a or to materialize.
369void ARMAsmPrinter::printSOImm2PartOperand(const MachineInstr *MI, int OpNum) {
370 const MachineOperand &MO = MI->getOperand(OpNum);
371 assert(MO.isImmediate() && "Not a valid so_imm value!");
Chris Lattnera96056a2007-12-30 20:49:49 +0000372 unsigned V1 = ARM_AM::getSOImmTwoPartFirst(MO.getImm());
373 unsigned V2 = ARM_AM::getSOImmTwoPartSecond(MO.getImm());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374 printSOImm(O, ARM_AM::getSOImmVal(V1), TAI);
375 O << "\n\torr";
376 printPredicateOperand(MI, 2);
377 O << " ";
378 printOperand(MI, 0);
379 O << ", ";
380 printOperand(MI, 0);
381 O << ", ";
382 printSOImm(O, ARM_AM::getSOImmVal(V2), TAI);
383}
384
385// so_reg is a 4-operand unit corresponding to register forms of the A5.1
386// "Addressing Mode 1 - Data-processing operands" forms. This includes:
387// REG 0 0 - e.g. R5
388// REG REG 0,SH_OPC - e.g. R5, ROR R3
389// REG 0 IMM,SH_OPC - e.g. R5, LSL #3
390void ARMAsmPrinter::printSORegOperand(const MachineInstr *MI, int Op) {
391 const MachineOperand &MO1 = MI->getOperand(Op);
392 const MachineOperand &MO2 = MI->getOperand(Op+1);
393 const MachineOperand &MO3 = MI->getOperand(Op+2);
394
395 assert(MRegisterInfo::isPhysicalRegister(MO1.getReg()));
396 O << TM.getRegisterInfo()->get(MO1.getReg()).Name;
397
398 // Print the shift opc.
399 O << ", "
Chris Lattnera96056a2007-12-30 20:49:49 +0000400 << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO3.getImm()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000401 << " ";
402
403 if (MO2.getReg()) {
404 assert(MRegisterInfo::isPhysicalRegister(MO2.getReg()));
405 O << TM.getRegisterInfo()->get(MO2.getReg()).Name;
406 assert(ARM_AM::getSORegOffset(MO3.getImm()) == 0);
407 } else {
408 O << "#" << ARM_AM::getSORegOffset(MO3.getImm());
409 }
410}
411
412void ARMAsmPrinter::printAddrMode2Operand(const MachineInstr *MI, int Op) {
413 const MachineOperand &MO1 = MI->getOperand(Op);
414 const MachineOperand &MO2 = MI->getOperand(Op+1);
415 const MachineOperand &MO3 = MI->getOperand(Op+2);
416
417 if (!MO1.isRegister()) { // FIXME: This is for CP entries, but isn't right.
418 printOperand(MI, Op);
419 return;
420 }
421
422 O << "[" << TM.getRegisterInfo()->get(MO1.getReg()).Name;
423
424 if (!MO2.getReg()) {
425 if (ARM_AM::getAM2Offset(MO3.getImm())) // Don't print +0.
426 O << ", #"
427 << (char)ARM_AM::getAM2Op(MO3.getImm())
428 << ARM_AM::getAM2Offset(MO3.getImm());
429 O << "]";
430 return;
431 }
432
433 O << ", "
434 << (char)ARM_AM::getAM2Op(MO3.getImm())
435 << TM.getRegisterInfo()->get(MO2.getReg()).Name;
436
437 if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
438 O << ", "
Chris Lattnera96056a2007-12-30 20:49:49 +0000439 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440 << " #" << ShImm;
441 O << "]";
442}
443
444void ARMAsmPrinter::printAddrMode2OffsetOperand(const MachineInstr *MI, int Op){
445 const MachineOperand &MO1 = MI->getOperand(Op);
446 const MachineOperand &MO2 = MI->getOperand(Op+1);
447
448 if (!MO1.getReg()) {
449 unsigned ImmOffs = ARM_AM::getAM2Offset(MO2.getImm());
450 assert(ImmOffs && "Malformed indexed load / store!");
451 O << "#"
452 << (char)ARM_AM::getAM2Op(MO2.getImm())
453 << ImmOffs;
454 return;
455 }
456
457 O << (char)ARM_AM::getAM2Op(MO2.getImm())
458 << TM.getRegisterInfo()->get(MO1.getReg()).Name;
459
460 if (unsigned ShImm = ARM_AM::getAM2Offset(MO2.getImm()))
461 O << ", "
Chris Lattnera96056a2007-12-30 20:49:49 +0000462 << ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO2.getImm()))
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463 << " #" << ShImm;
464}
465
466void ARMAsmPrinter::printAddrMode3Operand(const MachineInstr *MI, int Op) {
467 const MachineOperand &MO1 = MI->getOperand(Op);
468 const MachineOperand &MO2 = MI->getOperand(Op+1);
469 const MachineOperand &MO3 = MI->getOperand(Op+2);
470
471 assert(MRegisterInfo::isPhysicalRegister(MO1.getReg()));
472 O << "[" << TM.getRegisterInfo()->get(MO1.getReg()).Name;
473
474 if (MO2.getReg()) {
475 O << ", "
476 << (char)ARM_AM::getAM3Op(MO3.getImm())
477 << TM.getRegisterInfo()->get(MO2.getReg()).Name
478 << "]";
479 return;
480 }
481
482 if (unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm()))
483 O << ", #"
484 << (char)ARM_AM::getAM3Op(MO3.getImm())
485 << ImmOffs;
486 O << "]";
487}
488
489void ARMAsmPrinter::printAddrMode3OffsetOperand(const MachineInstr *MI, int Op){
490 const MachineOperand &MO1 = MI->getOperand(Op);
491 const MachineOperand &MO2 = MI->getOperand(Op+1);
492
493 if (MO1.getReg()) {
494 O << (char)ARM_AM::getAM3Op(MO2.getImm())
495 << TM.getRegisterInfo()->get(MO1.getReg()).Name;
496 return;
497 }
498
499 unsigned ImmOffs = ARM_AM::getAM3Offset(MO2.getImm());
500 assert(ImmOffs && "Malformed indexed load / store!");
501 O << "#"
502 << (char)ARM_AM::getAM3Op(MO2.getImm())
503 << ImmOffs;
504}
505
506void ARMAsmPrinter::printAddrMode4Operand(const MachineInstr *MI, int Op,
507 const char *Modifier) {
508 const MachineOperand &MO1 = MI->getOperand(Op);
509 const MachineOperand &MO2 = MI->getOperand(Op+1);
510 ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MO2.getImm());
511 if (Modifier && strcmp(Modifier, "submode") == 0) {
512 if (MO1.getReg() == ARM::SP) {
513 bool isLDM = (MI->getOpcode() == ARM::LDM ||
514 MI->getOpcode() == ARM::LDM_RET);
515 O << ARM_AM::getAMSubModeAltStr(Mode, isLDM);
516 } else
517 O << ARM_AM::getAMSubModeStr(Mode);
518 } else {
519 printOperand(MI, Op);
520 if (ARM_AM::getAM4WBFlag(MO2.getImm()))
521 O << "!";
522 }
523}
524
525void ARMAsmPrinter::printAddrMode5Operand(const MachineInstr *MI, int Op,
526 const char *Modifier) {
527 const MachineOperand &MO1 = MI->getOperand(Op);
528 const MachineOperand &MO2 = MI->getOperand(Op+1);
529
530 if (!MO1.isRegister()) { // FIXME: This is for CP entries, but isn't right.
531 printOperand(MI, Op);
532 return;
533 }
534
535 assert(MRegisterInfo::isPhysicalRegister(MO1.getReg()));
536
537 if (Modifier && strcmp(Modifier, "submode") == 0) {
538 ARM_AM::AMSubMode Mode = ARM_AM::getAM5SubMode(MO2.getImm());
539 if (MO1.getReg() == ARM::SP) {
540 bool isFLDM = (MI->getOpcode() == ARM::FLDMD ||
541 MI->getOpcode() == ARM::FLDMS);
542 O << ARM_AM::getAMSubModeAltStr(Mode, isFLDM);
543 } else
544 O << ARM_AM::getAMSubModeStr(Mode);
545 return;
546 } else if (Modifier && strcmp(Modifier, "base") == 0) {
547 // Used for FSTM{D|S} and LSTM{D|S} operations.
548 O << TM.getRegisterInfo()->get(MO1.getReg()).Name;
549 if (ARM_AM::getAM5WBFlag(MO2.getImm()))
550 O << "!";
551 return;
552 }
553
554 O << "[" << TM.getRegisterInfo()->get(MO1.getReg()).Name;
555
556 if (unsigned ImmOffs = ARM_AM::getAM5Offset(MO2.getImm())) {
557 O << ", #"
558 << (char)ARM_AM::getAM5Op(MO2.getImm())
559 << ImmOffs*4;
560 }
561 O << "]";
562}
563
564void ARMAsmPrinter::printAddrModePCOperand(const MachineInstr *MI, int Op,
565 const char *Modifier) {
566 if (Modifier && strcmp(Modifier, "label") == 0) {
567 printPCLabel(MI, Op+1);
568 return;
569 }
570
571 const MachineOperand &MO1 = MI->getOperand(Op);
572 assert(MRegisterInfo::isPhysicalRegister(MO1.getReg()));
573 O << "[pc, +" << TM.getRegisterInfo()->get(MO1.getReg()).Name << "]";
574}
575
576void
577ARMAsmPrinter::printThumbAddrModeRROperand(const MachineInstr *MI, int Op) {
578 const MachineOperand &MO1 = MI->getOperand(Op);
579 const MachineOperand &MO2 = MI->getOperand(Op+1);
580 O << "[" << TM.getRegisterInfo()->get(MO1.getReg()).Name;
581 O << ", " << TM.getRegisterInfo()->get(MO2.getReg()).Name << "]";
582}
583
584void
585ARMAsmPrinter::printThumbAddrModeRI5Operand(const MachineInstr *MI, int Op,
586 unsigned Scale) {
587 const MachineOperand &MO1 = MI->getOperand(Op);
588 const MachineOperand &MO2 = MI->getOperand(Op+1);
589 const MachineOperand &MO3 = MI->getOperand(Op+2);
590
591 if (!MO1.isRegister()) { // FIXME: This is for CP entries, but isn't right.
592 printOperand(MI, Op);
593 return;
594 }
595
596 O << "[" << TM.getRegisterInfo()->get(MO1.getReg()).Name;
597 if (MO3.getReg())
598 O << ", " << TM.getRegisterInfo()->get(MO3.getReg()).Name;
599 else if (unsigned ImmOffs = MO2.getImm()) {
600 O << ", #" << ImmOffs;
601 if (Scale > 1)
602 O << " * " << Scale;
603 }
604 O << "]";
605}
606
607void
608ARMAsmPrinter::printThumbAddrModeS1Operand(const MachineInstr *MI, int Op) {
609 printThumbAddrModeRI5Operand(MI, Op, 1);
610}
611void
612ARMAsmPrinter::printThumbAddrModeS2Operand(const MachineInstr *MI, int Op) {
613 printThumbAddrModeRI5Operand(MI, Op, 2);
614}
615void
616ARMAsmPrinter::printThumbAddrModeS4Operand(const MachineInstr *MI, int Op) {
617 printThumbAddrModeRI5Operand(MI, Op, 4);
618}
619
620void ARMAsmPrinter::printThumbAddrModeSPOperand(const MachineInstr *MI,int Op) {
621 const MachineOperand &MO1 = MI->getOperand(Op);
622 const MachineOperand &MO2 = MI->getOperand(Op+1);
623 O << "[" << TM.getRegisterInfo()->get(MO1.getReg()).Name;
624 if (unsigned ImmOffs = MO2.getImm())
625 O << ", #" << ImmOffs << " * 4";
626 O << "]";
627}
628
629void ARMAsmPrinter::printPredicateOperand(const MachineInstr *MI, int opNum) {
Chris Lattnera96056a2007-12-30 20:49:49 +0000630 ARMCC::CondCodes CC = (ARMCC::CondCodes)MI->getOperand(opNum).getImm();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631 if (CC != ARMCC::AL)
632 O << ARMCondCodeToString(CC);
633}
634
635void ARMAsmPrinter::printSBitModifierOperand(const MachineInstr *MI, int opNum){
636 unsigned Reg = MI->getOperand(opNum).getReg();
637 if (Reg) {
638 assert(Reg == ARM::CPSR && "Expect ARM CPSR register!");
639 O << 's';
640 }
641}
642
643void ARMAsmPrinter::printPCLabel(const MachineInstr *MI, int opNum) {
Chris Lattnera96056a2007-12-30 20:49:49 +0000644 int Id = (int)MI->getOperand(opNum).getImm();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 O << TAI->getPrivateGlobalPrefix() << "PC" << Id;
646}
647
648void ARMAsmPrinter::printRegisterList(const MachineInstr *MI, int opNum) {
649 O << "{";
650 for (unsigned i = opNum, e = MI->getNumOperands(); i != e; ++i) {
651 printOperand(MI, i);
652 if (i != e-1) O << ", ";
653 }
654 O << "}";
655}
656
657void ARMAsmPrinter::printCPInstOperand(const MachineInstr *MI, int OpNo,
658 const char *Modifier) {
659 assert(Modifier && "This operand only works with a modifier!");
660 // There are two aspects to a CONSTANTPOOL_ENTRY operand, the label and the
661 // data itself.
662 if (!strcmp(Modifier, "label")) {
663 unsigned ID = MI->getOperand(OpNo).getImm();
Evan Cheng477013c2007-10-14 05:57:21 +0000664 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
665 << '_' << ID << ":\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 } else {
667 assert(!strcmp(Modifier, "cpentry") && "Unknown modifier for CPE");
Chris Lattner6017d482007-12-30 23:10:15 +0000668 unsigned CPI = MI->getOperand(OpNo).getIndex();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669
670 const MachineConstantPoolEntry &MCPE = // Chasing pointers is fun?
671 MI->getParent()->getParent()->getConstantPool()->getConstants()[CPI];
672
673 if (MCPE.isMachineConstantPoolEntry())
674 EmitMachineConstantPoolValue(MCPE.Val.MachineCPVal);
675 else {
676 EmitGlobalConstant(MCPE.Val.ConstVal);
677 // remember to emit the weak reference
678 if (const GlobalValue *GV = dyn_cast<GlobalValue>(MCPE.Val.ConstVal))
679 if (GV->hasExternalWeakLinkage())
680 ExtWeakSymbols.insert(GV);
681 }
682 }
683}
684
685void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNo) {
686 const MachineOperand &MO1 = MI->getOperand(OpNo);
687 const MachineOperand &MO2 = MI->getOperand(OpNo+1); // Unique Id
Chris Lattner6017d482007-12-30 23:10:15 +0000688 unsigned JTI = MO1.getIndex();
Evan Cheng477013c2007-10-14 05:57:21 +0000689 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
Chris Lattnera96056a2007-12-30 20:49:49 +0000690 << '_' << JTI << '_' << MO2.getImm() << ":\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691
692 const char *JTEntryDirective = TAI->getJumpTableDirective();
693 if (!JTEntryDirective)
694 JTEntryDirective = TAI->getData32bitsDirective();
695
696 const MachineFunction *MF = MI->getParent()->getParent();
697 MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
698 const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
699 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
700 bool UseSet= TAI->getSetDirective() && TM.getRelocationModel() == Reloc::PIC_;
701 std::set<MachineBasicBlock*> JTSets;
702 for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
703 MachineBasicBlock *MBB = JTBBs[i];
704 if (UseSet && JTSets.insert(MBB).second)
Chris Lattnera96056a2007-12-30 20:49:49 +0000705 printPICJumpTableSetLabel(JTI, MO2.getImm(), MBB);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706
707 O << JTEntryDirective << ' ';
708 if (UseSet)
Evan Cheng477013c2007-10-14 05:57:21 +0000709 O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
Chris Lattnera96056a2007-12-30 20:49:49 +0000710 << '_' << JTI << '_' << MO2.getImm()
Evan Cheng477013c2007-10-14 05:57:21 +0000711 << "_set_" << MBB->getNumber();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 else if (TM.getRelocationModel() == Reloc::PIC_) {
713 printBasicBlockLabel(MBB, false, false);
714 // If the arch uses custom Jump Table directives, don't calc relative to JT
715 if (!TAI->getJumpTableDirective())
716 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
Chris Lattnera96056a2007-12-30 20:49:49 +0000717 << getFunctionNumber() << '_' << JTI << '_' << MO2.getImm();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 } else
719 printBasicBlockLabel(MBB, false, false);
720 if (i != e-1)
721 O << '\n';
722 }
723}
724
725
726bool ARMAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
727 unsigned AsmVariant, const char *ExtraCode){
728 // Does this asm operand have a single letter operand modifier?
729 if (ExtraCode && ExtraCode[0]) {
730 if (ExtraCode[1] != 0) return true; // Unknown modifier.
731
732 switch (ExtraCode[0]) {
733 default: return true; // Unknown modifier.
734 case 'c': // Don't print "$" before a global var name or constant.
735 case 'P': // Print a VFP double precision register.
736 printOperand(MI, OpNo);
737 return false;
738 case 'Q':
739 if (TM.getTargetData()->isLittleEndian())
740 break;
741 // Fallthrough
742 case 'R':
743 if (TM.getTargetData()->isBigEndian())
744 break;
745 // Fallthrough
746 case 'H': // Write second word of DI / DF reference.
747 // Verify that this operand has two consecutive registers.
748 if (!MI->getOperand(OpNo).isRegister() ||
749 OpNo+1 == MI->getNumOperands() ||
750 !MI->getOperand(OpNo+1).isRegister())
751 return true;
752 ++OpNo; // Return the high-part.
753 }
754 }
755
756 printOperand(MI, OpNo);
757 return false;
758}
759
760void ARMAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
761 ++EmittedInsts;
762
763 int Opc = MI->getOpcode();
764 switch (Opc) {
765 case ARM::CONSTPOOL_ENTRY:
766 if (!InCPMode && AFI->isThumbFunction()) {
767 EmitAlignment(2);
768 InCPMode = true;
769 }
770 break;
771 default: {
772 if (InCPMode && AFI->isThumbFunction())
773 InCPMode = false;
774 switch (Opc) {
775 case ARM::PICADD:
776 case ARM::PICLD:
777 case ARM::PICLDZH:
778 case ARM::PICLDZB:
779 case ARM::PICLDH:
780 case ARM::PICLDB:
781 case ARM::PICLDSH:
782 case ARM::PICLDSB:
783 case ARM::PICSTR:
784 case ARM::PICSTRH:
785 case ARM::PICSTRB:
786 case ARM::tPICADD:
787 break;
788 default:
789 O << "\t";
790 break;
791 }
792 }}
793
794 // Call the autogenerated instruction printer routines.
795 printInstruction(MI);
796}
797
798bool ARMAsmPrinter::doInitialization(Module &M) {
799 // Emit initial debug information.
800 DW.BeginModule(&M);
801
Dan Gohman4a558a32007-07-25 19:33:14 +0000802 bool Result = AsmPrinter::doInitialization(M);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803
804 // Darwin wants symbols to be quoted if they have complex names.
805 if (Subtarget->isTargetDarwin())
806 Mang->setUseQuotes(true);
807
Dan Gohman4a558a32007-07-25 19:33:14 +0000808 return Result;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809}
810
811bool ARMAsmPrinter::doFinalization(Module &M) {
812 const TargetData *TD = TM.getTargetData();
813
814 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
815 I != E; ++I) {
816 if (!I->hasInitializer()) // External global require no code
817 continue;
818
819 if (EmitSpecialLLVMGlobal(I)) {
820 if (Subtarget->isTargetDarwin() &&
821 TM.getRelocationModel() == Reloc::Static) {
822 if (I->getName() == "llvm.global_ctors")
823 O << ".reference .constructors_used\n";
824 else if (I->getName() == "llvm.global_dtors")
825 O << ".reference .destructors_used\n";
826 }
827 continue;
828 }
829
830 std::string name = Mang->getValueName(I);
831 Constant *C = I->getInitializer();
832 const Type *Type = C->getType();
Duncan Sands8157ef42007-11-05 00:04:43 +0000833 unsigned Size = TD->getABITypeSize(Type);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 unsigned Align = TD->getPreferredAlignmentLog(I);
835
836 const char *VisibilityDirective = NULL;
837 if (I->hasHiddenVisibility())
838 VisibilityDirective = TAI->getHiddenDirective();
839 else if (I->hasProtectedVisibility())
840 VisibilityDirective = TAI->getProtectedDirective();
841
842 if (VisibilityDirective)
843 O << VisibilityDirective << name << "\n";
844
845 if (Subtarget->isTargetELF())
846 O << "\t.type " << name << ",%object\n";
847
Lauro Ramos Venancio7eccd2b2007-11-05 18:33:37 +0000848 if (C->isNullValue() && !I->hasSection() && !I->isThreadLocal()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 if (I->hasExternalLinkage()) {
850 if (const char *Directive = TAI->getZeroFillDirective()) {
851 O << "\t.globl\t" << name << "\n";
852 O << Directive << "__DATA__, __common, " << name << ", "
853 << Size << ", " << Align << "\n";
854 continue;
855 }
856 }
857
Dale Johannesen42c3dcf2008-01-17 23:36:04 +0000858 if (I->hasInternalLinkage() || I->hasWeakLinkage() ||
859 I->hasLinkOnceLinkage()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
861 if (!NoZerosInBSS && TAI->getBSSSection())
862 SwitchToDataSection(TAI->getBSSSection(), I);
863 else
864 SwitchToDataSection(TAI->getDataSection(), I);
865 if (TAI->getLCOMMDirective() != NULL) {
866 if (I->hasInternalLinkage()) {
867 O << TAI->getLCOMMDirective() << name << "," << Size;
868 if (Subtarget->isTargetDarwin())
869 O << "," << Align;
870 } else
871 O << TAI->getCOMMDirective() << name << "," << Size;
872 } else {
873 if (I->hasInternalLinkage())
874 O << "\t.local\t" << name << "\n";
875 O << TAI->getCOMMDirective() << name << "," << Size;
876 if (TAI->getCOMMDirectiveTakesAlignment())
877 O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
878 }
879 O << "\t\t" << TAI->getCommentString() << " " << I->getName() << "\n";
880 continue;
881 }
882 }
883
884 switch (I->getLinkage()) {
885 case GlobalValue::LinkOnceLinkage:
886 case GlobalValue::WeakLinkage:
887 if (Subtarget->isTargetDarwin()) {
888 O << "\t.globl " << name << "\n"
889 << "\t.weak_definition " << name << "\n";
Dale Johanneseneafd8b52008-01-11 01:59:45 +0000890 SwitchToDataSection("\t.section __DATA,__datacoal_nt,coalesced", I);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 } else {
892 std::string SectionName("\t.section\t.llvm.linkonce.d." +
893 name +
894 ",\"aw\",%progbits");
895 SwitchToDataSection(SectionName.c_str(), I);
896 O << "\t.weak " << name << "\n";
897 }
898 break;
899 case GlobalValue::AppendingLinkage:
900 // FIXME: appending linkage variables should go into a section of
901 // their name or something. For now, just emit them as external.
902 case GlobalValue::ExternalLinkage:
903 O << "\t.globl " << name << "\n";
904 // FALL THROUGH
905 case GlobalValue::InternalLinkage: {
906 if (I->isConstant()) {
907 const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
908 if (TAI->getCStringSection() && CVA && CVA->isCString()) {
909 SwitchToDataSection(TAI->getCStringSection(), I);
910 break;
911 }
912 }
913 // FIXME: special handling for ".ctors" & ".dtors" sections
914 if (I->hasSection() &&
915 (I->getSection() == ".ctors" ||
916 I->getSection() == ".dtors")) {
917 assert(!Subtarget->isTargetDarwin());
918 std::string SectionName = ".section " + I->getSection();
919 SectionName += ",\"aw\",%progbits";
920 SwitchToDataSection(SectionName.c_str());
Dale Johannesenae4f62f2008-01-23 00:58:14 +0000921 } else if (I->hasSection() && Subtarget->isTargetDarwin()) {
922 // Honor all section names on Darwin; ObjC uses this
923 std::string SectionName = ".section " + I->getSection();
924 SwitchToDataSection(SectionName.c_str());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 } else {
926 if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection())
927 SwitchToDataSection(I->isThreadLocal() ? TAI->getTLSBSSSection() :
928 TAI->getBSSSection(), I);
929 else if (!I->isConstant())
930 SwitchToDataSection(I->isThreadLocal() ? TAI->getTLSDataSection() :
931 TAI->getDataSection(), I);
932 else if (I->isThreadLocal())
933 SwitchToDataSection(TAI->getTLSDataSection());
934 else {
935 // Read-only data.
936 bool HasReloc = C->ContainsRelocations();
937 if (HasReloc &&
938 Subtarget->isTargetDarwin() &&
939 TM.getRelocationModel() != Reloc::Static)
940 SwitchToDataSection("\t.const_data\n");
941 else if (!HasReloc && Size == 4 &&
942 TAI->getFourByteConstantSection())
943 SwitchToDataSection(TAI->getFourByteConstantSection(), I);
944 else if (!HasReloc && Size == 8 &&
945 TAI->getEightByteConstantSection())
946 SwitchToDataSection(TAI->getEightByteConstantSection(), I);
947 else if (!HasReloc && Size == 16 &&
948 TAI->getSixteenByteConstantSection())
949 SwitchToDataSection(TAI->getSixteenByteConstantSection(), I);
950 else if (TAI->getReadOnlySection())
951 SwitchToDataSection(TAI->getReadOnlySection(), I);
952 else
953 SwitchToDataSection(TAI->getDataSection(), I);
954 }
955 }
956
957 break;
958 }
959 default:
960 assert(0 && "Unknown linkage type!");
961 break;
962 }
963
964 EmitAlignment(Align, I);
965 O << name << ":\t\t\t\t" << TAI->getCommentString() << " " << I->getName()
966 << "\n";
967 if (TAI->hasDotTypeDotSizeDirective())
968 O << "\t.size " << name << ", " << Size << "\n";
969 // If the initializer is a extern weak symbol, remember to emit the weak
970 // reference!
971 if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
972 if (GV->hasExternalWeakLinkage())
973 ExtWeakSymbols.insert(GV);
974
975 EmitGlobalConstant(C);
976 O << '\n';
977 }
978
979 if (Subtarget->isTargetDarwin()) {
980 SwitchToDataSection("");
981
982 // Output stubs for dynamically-linked functions
983 unsigned j = 1;
984 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
985 i != e; ++i, ++j) {
986 if (TM.getRelocationModel() == Reloc::PIC_)
987 SwitchToTextSection(".section __TEXT,__picsymbolstub4,symbol_stubs,"
988 "none,16", 0);
989 else
990 SwitchToTextSection(".section __TEXT,__symbol_stub4,symbol_stubs,"
991 "none,12", 0);
992
993 EmitAlignment(2);
994 O << "\t.code\t32\n";
995
996 O << "L" << *i << "$stub:\n";
997 O << "\t.indirect_symbol " << *i << "\n";
998 O << "\tldr ip, L" << *i << "$slp\n";
999 if (TM.getRelocationModel() == Reloc::PIC_) {
1000 O << "L" << *i << "$scv:\n";
1001 O << "\tadd ip, pc, ip\n";
1002 }
1003 O << "\tldr pc, [ip, #0]\n";
1004 O << "L" << *i << "$slp:\n";
1005 if (TM.getRelocationModel() == Reloc::PIC_)
1006 O << "\t.long\tL" << *i << "$lazy_ptr-(L" << *i << "$scv+8)\n";
1007 else
1008 O << "\t.long\tL" << *i << "$lazy_ptr\n";
1009 SwitchToDataSection(".lazy_symbol_pointer", 0);
1010 O << "L" << *i << "$lazy_ptr:\n";
1011 O << "\t.indirect_symbol " << *i << "\n";
1012 O << "\t.long\tdyld_stub_binding_helper\n";
1013 }
1014 O << "\n";
1015
1016 // Output non-lazy-pointers for external and common global variables.
Dan Gohman3f7d94b2007-10-03 19:26:29 +00001017 if (!GVNonLazyPtrs.empty())
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 SwitchToDataSection(".non_lazy_symbol_pointer", 0);
1019 for (std::set<std::string>::iterator i = GVNonLazyPtrs.begin(),
1020 e = GVNonLazyPtrs.end(); i != e; ++i) {
1021 O << "L" << *i << "$non_lazy_ptr:\n";
1022 O << "\t.indirect_symbol " << *i << "\n";
1023 O << "\t.long\t0\n";
1024 }
1025
1026 // Emit initial debug information.
1027 DW.EndModule();
1028
1029 // Funny Darwin hack: This flag tells the linker that no global symbols
1030 // contain code that falls through to other global symbols (e.g. the obvious
1031 // implementation of multiple entry points). If this doesn't occur, the
1032 // linker can safely perform dead code stripping. Since LLVM never
1033 // generates code that does this, it is always safe to set.
1034 O << "\t.subsections_via_symbols\n";
1035 } else {
1036 // Emit final debug information for ELF.
1037 DW.EndModule();
1038 }
1039
Dan Gohman4a558a32007-07-25 19:33:14 +00001040 return AsmPrinter::doFinalization(M);
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041}