diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp | 90 | 
1 files changed, 81 insertions, 9 deletions
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp b/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp index bc2472cebbeb..043ead7e62d9 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp +++ b/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp @@ -648,7 +648,7 @@ ABIArgInfo X86_32ABIInfo::getIndirectResult(QualType Ty, bool ByVal) const {    unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;    unsigned StackAlign = getTypeStackAlignInBytes(Ty, TypeAlign);    if (StackAlign == 0) -    return ABIArgInfo::getIndirect(0); +    return ABIArgInfo::getIndirect(4);    // If the stack alignment is less than the type alignment, realign the    // argument. @@ -1315,13 +1315,10 @@ ABIArgInfo X86_64ABIInfo::getIndirectResult(QualType Ty) const {    if (isRecordWithNonTrivialDestructorOrCopyConstructor(Ty))      return ABIArgInfo::getIndirect(0, /*ByVal=*/false); -  // Compute the byval alignment. We trust the back-end to honor the -  // minimum ABI alignment for byval, to make cleaner IR. -  const unsigned MinABIAlign = 8; -  unsigned Align = getContext().getTypeAlign(Ty) / 8; -  if (Align > MinABIAlign) -    return ABIArgInfo::getIndirect(Align); -  return ABIArgInfo::getIndirect(0); +  // Compute the byval alignment. We specify the alignment of the byval in all +  // cases so that the mid-level optimizer knows the alignment of the byval. +  unsigned Align = std::max(getContext().getTypeAlign(Ty) / 8, 8U); +  return ABIArgInfo::getIndirect(Align);  }  /// Get16ByteVectorType - The ABI specifies that a value should be passed in an @@ -2279,6 +2276,22 @@ public:    int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const {      return 13;    } + +  bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, +                               llvm::Value *Address) const { +    CodeGen::CGBuilderTy &Builder = CGF.Builder; +    llvm::LLVMContext &Context = CGF.getLLVMContext(); + +    const llvm::IntegerType *i8 = llvm::Type::getInt8Ty(Context); +    llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4); + +    // 0-15 are the 16 integer registers. +    AssignToArrayRange(Builder, Address, Four8, 0, 15); + +    return false; +  } + +  };  } @@ -2845,10 +2858,21 @@ void MSP430TargetCodeGenInfo::SetTargetAttributes(const Decl *D,  //===----------------------------------------------------------------------===//  namespace { +class MipsABIInfo : public ABIInfo { +public: +  MipsABIInfo(CodeGenTypes &CGT) : ABIInfo(CGT) {} + +  ABIArgInfo classifyReturnType(QualType RetTy) const; +  ABIArgInfo classifyArgumentType(QualType RetTy) const; +  virtual void computeInfo(CGFunctionInfo &FI) const; +  virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty, +                                 CodeGenFunction &CGF) const; +}; +  class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {  public:    MIPSTargetCodeGenInfo(CodeGenTypes &CGT) -    : TargetCodeGenInfo(new DefaultABIInfo(CGT)) {} +    : TargetCodeGenInfo(new MipsABIInfo(CGT)) {}    int getDwarfEHStackPointer(CodeGen::CodeGenModule &CGM) const {      return 29; @@ -2859,6 +2883,54 @@ public:  };  } +ABIArgInfo MipsABIInfo::classifyArgumentType(QualType Ty) const { +  if (isAggregateTypeForABI(Ty)) { +    // Ignore empty aggregates. +    if (getContext().getTypeSize(Ty) == 0) +      return ABIArgInfo::getIgnore(); + +    return ABIArgInfo::getIndirect(0); +  } + +  // Treat an enum type as its underlying type. +  if (const EnumType *EnumTy = Ty->getAs<EnumType>()) +    Ty = EnumTy->getDecl()->getIntegerType(); + +  return (Ty->isPromotableIntegerType() ? +          ABIArgInfo::getExtend() : ABIArgInfo::getDirect()); +} + +ABIArgInfo MipsABIInfo::classifyReturnType(QualType RetTy) const { +  if (RetTy->isVoidType()) +    return ABIArgInfo::getIgnore(); + +  if (isAggregateTypeForABI(RetTy)) { +    if (RetTy->isAnyComplexType()) +      return ABIArgInfo::getDirect(); + +    return ABIArgInfo::getIndirect(0); +  } + +  // Treat an enum type as its underlying type. +  if (const EnumType *EnumTy = RetTy->getAs<EnumType>()) +    RetTy = EnumTy->getDecl()->getIntegerType(); + +  return (RetTy->isPromotableIntegerType() ? +          ABIArgInfo::getExtend() : ABIArgInfo::getDirect()); +} + +void MipsABIInfo::computeInfo(CGFunctionInfo &FI) const { +  FI.getReturnInfo() = classifyReturnType(FI.getReturnType()); +  for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); +       it != ie; ++it) +    it->info = classifyArgumentType(it->type); +} + +llvm::Value* MipsABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty, +                                    CodeGenFunction &CGF) const { +  return 0; +} +  bool  MIPSTargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,                                                 llvm::Value *Address) const {  | 
