[llvm-branch-commits] [llvm-gcc-branch] r104830 - in /llvm-gcc-4.2/branches/Apple/Hermes/gcc: config/arm/arm.h config/i386/i386.h llvm-convert.cpp
Evan Cheng
evan.cheng at apple.com
Thu May 27 01:48:48 PDT 2010
Author: evancheng
Date: Thu May 27 03:48:48 2010
New Revision: 104830
URL: http://llvm.org/viewvc/llvm-project?rev=104830&view=rev
Log:
Merge 98165.
Modified:
llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/arm/arm.h
llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/i386/i386.h
llvm-gcc-4.2/branches/Apple/Hermes/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/arm/arm.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/arm/arm.h?rev=104830&r1=104829&r2=104830&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/arm/arm.h (original)
+++ llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/arm/arm.h Thu May 27 03:48:48 2010
@@ -3548,6 +3548,16 @@
DESTTY, OPS) \
TargetIntrinsicLower(EXP, BUILTIN_CODE, DESTLOC, RESULT, DESTTY, OPS);
+/* LLVM_GET_REG_NAME - The registers known to llvm as "r10", "r11", and "r12"
+ may have different names in GCC. Register "r12" is called "ip", and on
+ non-Darwin OSs, "r10" is "sl" and "r11" is "fp". Translate those names,
+ and use the default register names for everything else. */
+#define LLVM_GET_REG_NAME(REG_NAME, REG_NUM) \
+ ((REG_NUM) == 10 ? "r10" \
+ : (REG_NUM) == 11 ? "r11" \
+ : (REG_NUM) == 12 ? "r12" \
+ : reg_names[REG_NUM])
+
#endif /* ENABLE_LLVM */
/* LLVM LOCAL end */
Modified: llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/i386/i386.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/i386/i386.h?rev=104830&r1=104829&r2=104830&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/i386/i386.h (original)
+++ llvm-gcc-4.2/branches/Apple/Hermes/gcc/config/i386/i386.h Thu May 27 03:48:48 2010
@@ -3923,11 +3923,12 @@
DESTTY, OPS) \
TargetIntrinsicLower(EXP, BUILTIN_CODE, DESTLOC, RESULT, DESTTY, OPS);
-/* When extracting a register name for a constraint, use the string extracted
- from the magic symbol built for that register, rather than reg_names.
- The latter maps both AH and AL to the same thing, which means we can't
- distinguish them. */
-#define LLVM_DO_NOT_USE_REG_NAMES
+/* LLVM_GET_REG_NAME - When extracting a register name for a constraint, use
+ the string extracted from the magic symbol built for that register, rather
+ than reg_names. The latter maps both AH and AL to the same thing, which
+ means we can't distinguish them. */
+#define LLVM_GET_REG_NAME(REG_NAME, REG_NUM) \
+ ((REG_NAME) + (*(REG_NAME) == '%' ? 1 : 0))
/* Propagate code model setting to backend */
#define LLVM_SET_MACHINE_OPTIONS(argvec) \
Modified: llvm-gcc-4.2/branches/Apple/Hermes/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Hermes/gcc/llvm-convert.cpp?rev=104830&r1=104829&r2=104830&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Hermes/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Hermes/gcc/llvm-convert.cpp Thu May 27 03:48:48 2010
@@ -3995,6 +3995,11 @@
// ... Inline Assembly and Register Variables ...
//===----------------------------------------------------------------------===//
+// LLVM_GET_REG_NAME - Default to use GCC's register names. Targets may
+// override this to use different names for some registers.
+#ifndef LLVM_GET_REG_NAME
+#define LLVM_GET_REG_NAME(REG_NAME, REG_NUM) reg_names[REG_NUM]
+#endif
/// Reads from register variables are handled by emitting an inline asm node
/// that copies the value out of the specified register.
@@ -4012,7 +4017,9 @@
// Turn this into a 'tmp = call Ty asm "", "={reg}"()'.
FunctionType *FTy = FunctionType::get(Ty, std::vector<const Type*>(),false);
- const char *Name = reg_names[decode_reg_name(extractRegisterName(decl))];
+ const char *Name = extractRegisterName(decl);
+ int RegNum = decode_reg_name(Name);
+ Name = LLVM_GET_REG_NAME(Name, RegNum);
InlineAsm *IA = InlineAsm::get(FTy, "", "={"+std::string(Name)+"}", false);
CallInst *Call = Builder.CreateCall(IA);
@@ -4032,7 +4039,9 @@
ArgTys.push_back(ConvertType(TREE_TYPE(decl)));
FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), ArgTys, false);
- const char *Name = reg_names[decode_reg_name(extractRegisterName(decl))];
+ const char *Name = extractRegisterName(decl);
+ int RegNum = decode_reg_name(Name);
+ Name = LLVM_GET_REG_NAME(Name, RegNum);
InlineAsm *IA = InlineAsm::get(FTy, "", "{"+std::string(Name)+"}", true);
CallInst *Call = Builder.CreateCall(IA, RHS);
@@ -4403,23 +4412,6 @@
free((char *)ReplacementStrings[i]);
}
-// When extracting a register name from a DECL_HARD_REGISTER variable,
-// we normally want to look up RegNum in reg_names. This works on most
-// targets, where ADDITIONAL_REGISTER_NAMES are true synonyms. It does not
-// work on x86, where ADDITIONAL_REGISTER_NAMES are overlapping subregisters;
-// in particular AH and AL can't be distinguished if we go through reg_names.
-static const char* getConstraintRegNameFromGccTables(const char *RegName,
- unsigned int RegNum) {
-#ifdef LLVM_DO_NOT_USE_REG_NAMES
- (void)RegNum;
- if (*RegName == '%')
- RegName++;
- return RegName;
-#else
- return reg_names[RegNum];
-#endif
-}
-
Value *TreeToLLVM::EmitASM_EXPR(tree exp) {
unsigned NumInputs = list_length(ASM_INPUTS(exp));
unsigned NumOutputs = list_length(ASM_OUTPUTS(exp));
@@ -4538,7 +4530,7 @@
const char* RegName = extractRegisterName(Operand);
int RegNum = decode_reg_name(RegName);
if (RegNum >= 0) {
- RegName = getConstraintRegNameFromGccTables(RegName, RegNum);
+ RegName = LLVM_GET_REG_NAME(RegName, RegNum);
unsigned RegNameLen = strlen(RegName);
char *NewConstraint = (char*)alloca(RegNameLen+4);
NewConstraint[0] = '=';
@@ -4705,7 +4697,7 @@
const char *RegName = extractRegisterName(Val);
int RegNum = decode_reg_name(RegName);
if (RegNum >= 0) {
- RegName = getConstraintRegNameFromGccTables(RegName, RegNum);
+ RegName = LLVM_GET_REG_NAME(RegName, RegNum);
ConstraintStr += '{';
ConstraintStr += RegName;
ConstraintStr += '}';
@@ -4748,7 +4740,7 @@
ConstraintStr += ",~{memory}";
break;
default: // Normal register name.
- RegName = getConstraintRegNameFromGccTables(RegName, RegCode);
+ RegName = LLVM_GET_REG_NAME(RegName, RegCode);
ConstraintStr += ",~{";
ConstraintStr += RegName;
ConstraintStr += "}";
More information about the llvm-branch-commits
mailing list