- // Print out module-level global variables here.
- for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
- I != E; ++I) {
- if (!I->hasInitializer())
- continue; // External global require no code
-
- // Check to see if this is a special global used by LLVM, if so, emit it.
- if (EmitSpecialLLVMGlobal(I)) {
- if (Subtarget->isTargetDarwin() &&
- TM.getRelocationModel() == Reloc::Static) {
- if (I->getName() == "llvm.global_ctors")
- O << ".reference .constructors_used\n";
- else if (I->getName() == "llvm.global_dtors")
- O << ".reference .destructors_used\n";
- }
- continue;
- }
-
- std::string name = Mang->getValueName(I);
- Constant *C = I->getInitializer();
- const Type *Type = C->getType();
- unsigned Size = TD->getTypeSize(Type);
- unsigned Align = TD->getPreferredAlignmentLog(I);
-
- if (I->hasHiddenVisibility()) {
- if (const char *Directive = TAI->getHiddenDirective())
- O << Directive << name << "\n";
- } else if (I->hasProtectedVisibility()) {
- if (const char *Directive = TAI->getProtectedDirective())
- O << Directive << name << "\n";
- }
-
- if (Subtarget->isTargetELF())
- O << "\t.type\t" << name << ",@object\n";
-
- if (C->isNullValue() && !I->hasSection()) {
- if (I->hasExternalLinkage()) {
- if (const char *Directive = TAI->getZeroFillDirective()) {
- O << "\t.globl\t" << name << "\n";
- O << Directive << "__DATA__, __common, " << name << ", "
- << Size << ", " << Align << "\n";
- continue;
- }
- }
-
- if (!I->isThreadLocal() &&
- (I->hasInternalLinkage() || I->hasWeakLinkage() ||
- I->hasLinkOnceLinkage())) {
- if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
- if (!NoZerosInBSS && TAI->getBSSSection())
- SwitchToDataSection(TAI->getBSSSection(), I);
- else
- SwitchToDataSection(TAI->getDataSection(), I);
- if (TAI->getLCOMMDirective() != NULL) {
- if (I->hasInternalLinkage()) {
- O << TAI->getLCOMMDirective() << name << "," << Size;
- if (Subtarget->isTargetDarwin())
- O << "," << Align;
- } else
- O << TAI->getCOMMDirective() << name << "," << Size;
- } else {
- if (!Subtarget->isTargetCygMing()) {
- if (I->hasInternalLinkage())
- O << "\t.local\t" << name << "\n";
- }
- O << TAI->getCOMMDirective() << name << "," << Size;
- if (TAI->getCOMMDirectiveTakesAlignment())
- O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
+ // If this has a segment register, print it.
+ if (SegReg.getReg()) {
+ printOperand(MI, Op+4, O, Modifier, AsmVariant);
+ O << ':';
+ }
+
+ O << '[';
+
+ bool NeedPlus = false;
+ if (BaseReg.getReg()) {
+ printOperand(MI, Op, O, Modifier, AsmVariant);
+ NeedPlus = true;
+ }
+
+ if (IndexReg.getReg()) {
+ if (NeedPlus) O << " + ";
+ if (ScaleVal != 1)
+ O << ScaleVal << '*';
+ printOperand(MI, Op+2, O, Modifier, AsmVariant);
+ NeedPlus = true;
+ }
+
+ if (!DispSpec.isImm()) {
+ if (NeedPlus) O << " + ";
+ printOperand(MI, Op+3, O, Modifier, AsmVariant);
+ } else {
+ int64_t DispVal = DispSpec.getImm();
+ if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
+ if (NeedPlus) {
+ if (DispVal > 0)
+ O << " + ";
+ else {
+ O << " - ";
+ DispVal = -DispVal;