[llvm-branch-commits] [llvm-gcc-branch] r81255 - in /llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc: llvm-backend.cpp llvm-convert.cpp

Bill Wendling isanbard at gmail.com
Tue Sep 8 15:17:32 PDT 2009


Author: void
Date: Tue Sep  8 17:17:32 2009
New Revision: 81255

URL: http://llvm.org/viewvc/llvm-project?rev=81255&view=rev
Log:
$ svn merge -c 76208 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r76208 into '.':
U    gcc/llvm-backend.cpp
U    gcc/llvm-convert.cpp


Modified:
    llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-backend.cpp
    llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-backend.cpp?rev=81255&r1=81254&r2=81255&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-backend.cpp Tue Sep  8 17:17:32 2009
@@ -1412,12 +1412,9 @@
   int RegNumber = decode_reg_name(extractRegisterName(decl));
   const Type *Ty = ConvertType(TREE_TYPE(decl));
 
-  // If this has already been processed, don't emit duplicate error messages.
-  if (DECL_LLVM_SET_P(decl)) {
-    // Error state encoded into DECL_LLVM.
-    return cast<ConstantInt>(DECL_LLVM(decl))->getZExtValue();
-  }
-  
+  if (errorcount || sorrycount)
+    return true;  // Do not process broken code.
+
   /* Detect errors in declaring global registers.  */
   if (RegNumber == -1)
     error("%Jregister name not specified for %qD", decl, decl);
@@ -1438,11 +1435,10 @@
   else {
     if (TREE_THIS_VOLATILE(decl))
       warning(0, "volatile register variables don%'t work as you might wish");
-    
-    SET_DECL_LLVM(decl, ConstantInt::getFalse());
+
     return false;  // Everything ok.
   }
-  SET_DECL_LLVM(decl, ConstantInt::getTrue());
+
   return true;
 }
 

Modified: llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp?rev=81255&r1=81254&r2=81255&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp Tue Sep  8 17:17:32 2009
@@ -2075,6 +2075,24 @@
 //                           ... Expressions ...
 //===----------------------------------------------------------------------===//
 
+static bool canEmitRegisterVariable(tree exp) {
+  // Only variables can be marked as 'register'.
+  if (TREE_CODE(exp) != VAR_DECL || !DECL_REGISTER(exp))
+    return false;
+
+  // We can emit inline assembler for access to global register variables.
+  if (TREE_STATIC(exp) || DECL_EXTERNAL(exp) || TREE_PUBLIC(exp))
+    return true;
+
+  // Emit inline asm if this is local variable with assembler name on it.
+  if (DECL_ASSEMBLER_NAME_SET_P(exp))
+    return true;
+
+  // Otherwise - it's normal automatic variable.
+  return false;
+}
+
+
 /// EmitLoadOfLValue - When an l-value expression is used in a context that
 /// requires an r-value, this method emits the lvalue computation, then loads
 /// the result.
@@ -2091,8 +2109,7 @@
     DECL_GIMPLE_FORMAL_TEMP_P(exp) = 0;
     EmitAutomaticVariableDecl(exp);
     // Fall through.
-  } else if (TREE_CODE(exp) == VAR_DECL && DECL_REGISTER(exp) &&
-             TREE_STATIC(exp)) {
+  } else if (canEmitRegisterVariable(exp)) {
     // If this is a register variable, EmitLV can't handle it (there is no
     // l-value of a register variable).  Emit an inline asm node that copies the
     // value out of the specified register.
@@ -2762,8 +2779,7 @@
     Builder.Insert(Cast);
     SET_DECL_LLVM(lhs, Cast);
     return Cast;
-  } else if (TREE_CODE(lhs) == VAR_DECL && DECL_REGISTER(lhs) &&
-             TREE_STATIC(lhs)) {
+  } else if (canEmitRegisterVariable(lhs)) {
     // If this is a store to a register variable, EmitLV can't handle the dest
     // (there is no l-value of a register variable).  Emit an inline asm node
     // that copies the value into the specified register.
@@ -3685,18 +3701,19 @@
 Value *TreeToLLVM::EmitReadOfRegisterVariable(tree decl,
                                               const MemRef *DestLoc) {
   const Type *Ty = ConvertType(TREE_TYPE(decl));
-  
+
   // If there was an error, return something bogus.
   if (ValidateRegisterVariable(decl)) {
     if (Ty->isSingleValueType())
       return UndefValue::get(Ty);
     return 0;   // Just don't copy something into DestLoc.
   }
-  
+
   // Turn this into a 'tmp = call Ty asm "", "={reg}"()'.
   FunctionType *FTy = FunctionType::get(Ty, std::vector<const Type*>(),false);
-  
-  const char *Name = extractRegisterName(decl);
+
+  const char *Name = reg_names[decode_reg_name(extractRegisterName(decl))];
+
   InlineAsm *IA = InlineAsm::get(FTy, "", "={"+std::string(Name)+"}", false);
   CallInst *Call = Builder.CreateCall(IA);
   Call->setDoesNotThrow();
@@ -3709,13 +3726,14 @@
   // If there was an error, bail out.
   if (ValidateRegisterVariable(decl))
     return;
-  
+
   // Turn this into a 'call void asm sideeffect "", "{reg}"(Ty %RHS)'.
   std::vector<const Type*> ArgTys;
   ArgTys.push_back(ConvertType(TREE_TYPE(decl)));
   FunctionType *FTy = FunctionType::get(Type::VoidTy, ArgTys, false);
-  
-  const char *Name = extractRegisterName(decl);
+
+  const char *Name = reg_names[decode_reg_name(extractRegisterName(decl))];
+
   InlineAsm *IA = InlineAsm::get(FTy, "", "{"+std::string(Name)+"}", true);
   CallInst *Call = Builder.CreateCall(IA, RHS);
   Call->setDoesNotThrow();





More information about the llvm-branch-commits mailing list