summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/CBackend/CBackend.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-01-28 13:31:35 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-01-28 13:31:35 +0000
commit037c867b54746b2dd93a0f26aa9007488be26157 (patch)
treeb0917e31d882558e442eb49274b17c4ef7b557df /llvm/lib/Target/CBackend/CBackend.cpp
parent262068d2daa3234d93a2d63a7123d61fce5eb7ec (diff)
downloadbcm5719-llvm-037c867b54746b2dd93a0f26aa9007488be26157.tar.gz
bcm5719-llvm-037c867b54746b2dd93a0f26aa9007488be26157.zip
Propagate changes from my local tree. This patch includes:
1. New parameter attribute called 'inreg'. It has meaning "place this parameter in registers, if possible". This is some generalization of gcc's regparm(n) attribute. It's currently used only in X86-32 backend. 2. Completely rewritten CC handling/lowering code inside X86 backend. Merged stdcall + c CCs and fastcall + fast CC. 3. Dropped CSRET CC. We cannot add struct return variant for each target-specific CC (e.g. stdcall + csretcc and so on). 4. Instead of CSRET CC introduced 'sret' parameter attribute. Setting in on first attribute has meaning 'This is hidden pointer to structure return. Handle it gently'. 5. Fixed small bug in llvm-extract + add new feature to FunctionExtraction pass, which relinks all internal-linkaged callees from deleted function to external linkage. This will allow further linking everything together. NOTEs: 1. Documentation will be updated soon. 2. llvm-upgrade should be improved to translate csret => sret. Before this, there will be some unexpected test fails. llvm-svn: 33597
Diffstat (limited to 'llvm/lib/Target/CBackend/CBackend.cpp')
-rw-r--r--llvm/lib/Target/CBackend/CBackend.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/llvm/lib/Target/CBackend/CBackend.cpp b/llvm/lib/Target/CBackend/CBackend.cpp
index 9faba6bd816..0c808131b60 100644
--- a/llvm/lib/Target/CBackend/CBackend.cpp
+++ b/llvm/lib/Target/CBackend/CBackend.cpp
@@ -1748,8 +1748,8 @@ void CWriter::printContainedStructs(const Type *Ty,
}
void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
- /// isCStructReturn - Should this function actually return a struct by-value?
- bool isCStructReturn = F->getCallingConv() == CallingConv::CSRet;
+ /// isStructReturn - Should this function actually return a struct by-value?
+ bool isStructReturn = F->getFunctionType()->isStructReturn();
if (F->hasInternalLinkage()) Out << "static ";
if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) ";
@@ -1778,7 +1778,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
// If this is a struct-return function, don't print the hidden
// struct-return argument.
- if (isCStructReturn) {
+ if (isStructReturn) {
assert(I != E && "Invalid struct return function!");
++I;
}
@@ -1804,7 +1804,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
// If this is a struct-return function, don't print the hidden
// struct-return argument.
- if (isCStructReturn) {
+ if (isStructReturn) {
assert(I != E && "Invalid struct return function!");
++I;
}
@@ -1832,7 +1832,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
// Get the return tpe for the function.
const Type *RetTy;
- if (!isCStructReturn)
+ if (!isStructReturn)
RetTy = F->getReturnType();
else {
// If this is a struct-return function, print the struct-return type.
@@ -1855,11 +1855,14 @@ static inline bool isFPIntBitCast(const Instruction &I) {
}
void CWriter::printFunction(Function &F) {
+ /// isStructReturn - Should this function actually return a struct by-value?
+ bool isStructReturn = F.getFunctionType()->isStructReturn();
+
printFunctionSignature(&F, false);
Out << " {\n";
// If this is a struct return function, handle the result with magic.
- if (F.getCallingConv() == CallingConv::CSRet) {
+ if (isStructReturn) {
const Type *StructTy =
cast<PointerType>(F.arg_begin()->getType())->getElementType();
Out << " ";
@@ -1977,7 +1980,10 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
//
void CWriter::visitReturnInst(ReturnInst &I) {
// If this is a struct return function, return the temporary struct.
- if (I.getParent()->getParent()->getCallingConv() == CallingConv::CSRet) {
+ bool isStructReturn = I.getParent()->getParent()->
+ getFunctionType()->isStructReturn();
+
+ if (isStructReturn) {
Out << " return StructReturn;\n";
return;
}
@@ -2468,9 +2474,12 @@ void CWriter::visitCallInst(CallInst &I) {
Value *Callee = I.getCalledValue();
+ const PointerType *PTy = cast<PointerType>(Callee->getType());
+ const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
+
// If this is a call to a struct-return function, assign to the first
// parameter instead of passing it to the call.
- bool isStructRet = I.getCallingConv() == CallingConv::CSRet;
+ bool isStructRet = FTy->isStructReturn();
if (isStructRet) {
Out << "*(";
writeOperand(I.getOperand(1));
@@ -2478,9 +2487,6 @@ void CWriter::visitCallInst(CallInst &I) {
}
if (I.isTailCall()) Out << " /*tail*/ ";
-
- const PointerType *PTy = cast<PointerType>(Callee->getType());
- const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
if (!WroteCallee) {
// If this is an indirect call to a struct return function, we need to cast
OpenPOWER on IntegriCloud