opening "-" automatically yields stdout.
[oota-llvm.git] / lib / CodeGen / AsmPrinter.cpp
index 366b8b398f9a1b8a971b89591b7b91631e05d5f1..16f26c429921319f512628b78417e2454615347b 100644 (file)
@@ -493,23 +493,12 @@ void AsmPrinter::PrintULEB128(unsigned Value) const {
   } while (Value);
 }
 
-/// SizeULEB128 - Compute the number of bytes required for an unsigned leb128
-/// value.
-unsigned AsmPrinter::SizeULEB128(unsigned Value) {
-  unsigned Size = 0;
-  do {
-    Value >>= 7;
-    Size += sizeof(int8_t);
-  } while (Value);
-  return Size;
-}
-
 /// PrintSLEB128 - Print a series of hexidecimal values (separated by commas)
 /// representing a signed leb128 value.
 void AsmPrinter::PrintSLEB128(int Value) const {
   int Sign = Value >> (8 * sizeof(Value) - 1);
   bool IsMore;
-  
+
   do {
     unsigned Byte = Value & 0x7f;
     Value >>= 7;
@@ -520,22 +509,6 @@ void AsmPrinter::PrintSLEB128(int Value) const {
   } while (IsMore);
 }
 
-/// SizeSLEB128 - Compute the number of bytes required for a signed leb128
-/// value.
-unsigned AsmPrinter::SizeSLEB128(int Value) {
-  unsigned Size = 0;
-  int Sign = Value >> (8 * sizeof(Value) - 1);
-  bool IsMore;
-  
-  do {
-    unsigned Byte = Value & 0x7f;
-    Value >>= 7;
-    IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
-    Size += sizeof(int8_t);
-  } while (IsMore);
-  return Size;
-}
-
 //===--------------------------------------------------------------------===//
 // Emission and print routines
 //
@@ -821,12 +794,13 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
 
       // We can emit the pointer value into this slot if the slot is an
       // integer slot greater or equal to the size of the pointer.
-      if (Ty->isInteger() &&
-          TD->getABITypeSize(Ty) >= TD->getABITypeSize(Op->getType()))
+      if (TD->getABITypeSize(Ty) >= TD->getABITypeSize(Op->getType()))
         return EmitConstantValueOnly(Op);
-      
-      assert(0 && "FIXME: Don't yet support this kind of constant cast expr");
+
+      O << "((";
       EmitConstantValueOnly(Op);
+      APInt ptrMask = APInt::getAllOnesValue(TD->getABITypeSizeInBits(Ty));
+      O << ") & " << ptrMask.toStringUnsigned() << ')';
       break;
     }
     case Instruction::Add:
@@ -1468,3 +1442,14 @@ void AsmPrinter::printSuffixedName(const char *Name, const char *Suffix,
 void AsmPrinter::printSuffixedName(const std::string &Name, const char* Suffix) {
   printSuffixedName(Name.c_str(), Suffix);
 }
+
+void AsmPrinter::printVisibility(const std::string& Name,
+                                 unsigned Visibility) const {
+  if (Visibility == GlobalValue::HiddenVisibility) {
+    if (const char *Directive = TAI->getHiddenDirective())
+      O << Directive << Name << '\n';
+  } else if (Visibility == GlobalValue::ProtectedVisibility) {
+    if (const char *Directive = TAI->getProtectedDirective())
+      O << Directive << Name << '\n';
+  }
+}