Remove some unnecessary includes of PseudoSourceValue.h.
[oota-llvm.git] / lib / VMCore / Core.cpp
index 96760579b656ceec3e06217d6c3a442c1cfcc706..a505e4b4f5e5dafc4ddbd51ef3fc6bc5308b1f51 100644 (file)
@@ -309,10 +309,10 @@ LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name)
 
 const char *LLVMGetStructName(LLVMTypeRef Ty)
 {
-    StructType *Type = unwrap<StructType>(Ty);
-    if (!Type->hasName())
-       return 0;
-    return Type->getName().data();
+  StructType *Type = unwrap<StructType>(Ty);
+  if (!Type->hasName())
+    return 0;
+  return Type->getName().data();
 }
 
 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
@@ -533,29 +533,29 @@ LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
 }
 
 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len) {
-    if (const MDString *S = dyn_cast<MDString>(unwrap(V))) {
-       *Len = S->getString().size();
-       return S->getString().data();
-    }
-    *Len = 0;
-    return 0;
+  if (const MDString *S = dyn_cast<MDString>(unwrap(V))) {
+    *Len = S->getString().size();
+    return S->getString().data();
+  }
+  *Len = 0;
+  return 0;
 }
 
 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name)
 {
-    if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) {
-       return N->getNumOperands();
-    }
-    return 0;
+  if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) {
+    return N->getNumOperands();
+  }
+  return 0;
 }
 
 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest)
 {
-    NamedMDNode *N = unwrap(M)->getNamedMetadata(name);
-    if (!N)
-       return;
-    for (unsigned i=0;i<N->getNumOperands();i++)
-       Dest[i] = wrap(N->getOperand(i));
+  NamedMDNode *N = unwrap(M)->getNamedMetadata(name);
+  if (!N)
+    return;
+  for (unsigned i=0;i<N->getNumOperands();i++)
+    Dest[i] = wrap(N->getOperand(i));
 }
 
 /*--.. Operations on scalar constants ......................................--*/
@@ -660,25 +660,23 @@ LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
 static LLVMOpcode map_to_llvmopcode(int opcode)
 {
     switch (opcode) {
+      default:
+        assert(0 && "Unhandled Opcode.");
 #define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
 #include "llvm/Instruction.def"
 #undef HANDLE_INST
-       default:
-           assert(false && "Unhandled Opcode.");
     }
-    return static_cast<LLVMOpcode>(0);
 }
 
 static int map_from_llvmopcode(LLVMOpcode code)
 {
     switch (code) {
+      default:
+        assert(0 && "Unhandled Opcode.");
 #define HANDLE_INST(num, opc, clas) case LLVM##opc: return num;
 #include "llvm/Instruction.def"
 #undef HANDLE_INST
-       default:
-           assert(false && "Unhandled Opcode.");
     }
-    return 0;
 }
 
 /*--.. Constant expressions ................................................--*/
@@ -1585,12 +1583,18 @@ void LLVMInstructionEraseFromParent(LLVMValueRef Inst) {
 }
 
 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst) {
-    if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
-       return (LLVMIntPredicate)I->getPredicate();
-    if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
-       if (CE->getOpcode() == Instruction::ICmp)
-           return (LLVMIntPredicate)CE->getPredicate();
-    return (LLVMIntPredicate)0;
+  if (ICmpInst *I = dyn_cast<ICmpInst>(unwrap(Inst)))
+    return (LLVMIntPredicate)I->getPredicate();
+  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(unwrap(Inst)))
+    if (CE->getOpcode() == Instruction::ICmp)
+      return (LLVMIntPredicate)CE->getPredicate();
+  return (LLVMIntPredicate)0;
+}
+
+LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst) {
+  if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
+    return map_to_llvmopcode(C->getOpcode());
+  return (LLVMOpcode)0;
 }
 
 /*--.. Call and invoke instructions ........................................--*/