[llvm-commits] [llvm] r106502 - /llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp

Chris Lattner sabre at nondot.org
Mon Jun 21 16:19:36 PDT 2010


Author: lattner
Date: Mon Jun 21 18:19:36 2010
New Revision: 106502

URL: http://llvm.org/viewvc/llvm-project?rev=106502&view=rev
Log:
add some support for blockaddress.  This isn't really enough to be useful,
but it will cover uses of blockaddress that are actually in a function.

Modified:
    llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp

Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=106502&r1=106501&r2=106502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Jun 21 18:19:36 2010
@@ -936,6 +936,9 @@
         Out << ", " << getCppName(CE->getOperand(i));
       Out << ");";
     }
+  } else if (const BlockAddress *BA = dyn_cast<BlockAddress>(CV)) {
+    Out << "Constant* " << constName << " = ";
+    Out << "BlockAddress::get(" << getOpName(BA->getBasicBlock()) << ");";
   } else {
     error("Bad Constant");
     Out << "Constant* " << constName << " = 0; ";
@@ -1088,9 +1091,8 @@
   // forward references. So, we get the names of all the operands in advance
   const unsigned Ops(I->getNumOperands());
   std::string* opNames = new std::string[Ops];
-  for (unsigned i = 0; i < Ops; i++) {
+  for (unsigned i = 0; i < Ops; i++)
     opNames[i] = getOpName(I->getOperand(i));
-  }
 
   switch (I->getOpcode()) {
   default:
@@ -1106,7 +1108,7 @@
   case Instruction::Br: {
     const BranchInst* br = cast<BranchInst>(I);
     Out << "BranchInst::Create(" ;
-    if (br->getNumOperands() == 3 ) {
+    if (br->getNumOperands() == 3) {
       Out << opNames[2] << ", "
           << opNames[1] << ", "
           << opNames[0] << ", ";





More information about the llvm-commits mailing list