Add explicit #includes of <iostream>
[oota-llvm.git] / lib / Target / X86 / X86IntelAsmPrinter.cpp
index 91982977c4b09b9020c4e43c983e2fa838e55532..2b91870e42ac41fc81177fc400b46948b7d67cc1 100755 (executable)
@@ -25,17 +25,17 @@ using namespace x86;
 /// method to print assembly for each instruction.
 ///
 bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
-  setupMachineFunction(MF);
+  SetupMachineFunction(MF);
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
-  O << "\t.text\n";
-  emitAlignment(4);
+  SwitchSection("\t.text\n", MF.getFunction());
+  EmitAlignment(4);
   O << "\t.globl\t" << CurrentFnName << "\n";
-  if (!forCygwin && !forDarwin)
+  if (HasDotTypeDotSizeDirective)
     O << "\t.type\t" << CurrentFnName << ", @function\n";
   O << CurrentFnName << ":\n";
 
@@ -44,7 +44,8 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
        I != E; ++I) {
     // Print a label for the basic block if there are any predecessors.
     if (I->pred_begin() != I->pred_end())
-      O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t"
+      O << PrivateGlobalPrefix << "BB" << CurrentFnName << "_" << I->getNumber()
+        << ":\t"
         << CommentString << " " << I->getBasicBlock()->getName() << "\n";
     for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
          II != E; ++II) {
@@ -58,6 +59,21 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   return false;
 }
 
+void X86IntelAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
+  unsigned char value = MI->getOperand(Op).getImmedValue();
+  assert(value <= 7 && "Invalid ssecc argument!");
+  switch (value) {
+  case 0: O << "eq"; break;
+  case 1: O << "lt"; break;
+  case 2: O << "le"; break;
+  case 3: O << "unord"; break;
+  case 4: O << "neq"; break;
+  case 5: O << "nlt"; break;
+  case 6: O << "nle"; break;
+  case 7: O << "ord"; break;
+  }
+}
+
 void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
                                  bool elideOffsetKeyword /* = false */) {
   const MRegisterInfo &RI = *TM.getRegisterInfo();
@@ -82,13 +98,14 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
     return;
   case MachineOperand::MO_MachineBasicBlock: {
     MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
-    O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction())
+    O << PrivateGlobalPrefix << "BB"
+      << Mang->getValueName(MBBOp->getParent()->getFunction())
       << "_" << MBBOp->getNumber () << "\t# "
       << MBBOp->getBasicBlock ()->getName ();
     return;
   }
   case MachineOperand::MO_PCRelativeDisp:
-    std::cerr << "Shouldn't use addPCDisp() when building X86 MachineInstrs";
+    assert(0 && "Shouldn't use addPCDisp() when building X86 MachineInstrs");
     abort ();
     return;
   case MachineOperand::MO_GlobalAddress: {
@@ -99,7 +116,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
     if (Offset > 0)
       O << " + " << Offset;
     else if (Offset < 0)
-      O << " - " << -Offset;
+      O << Offset;
     return;
   }
   case MachineOperand::MO_ExternalSymbol:
@@ -125,7 +142,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
     O << "]";
     return;
   } else if (BaseReg.isConstantPoolIndex()) {
-    O << "[.CPI" << CurrentFnName << "_"
+    O << "[" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
       << BaseReg.getConstantPoolIndex();
 
     if (IndexReg.getReg()) {