Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: lib/Target/X86/X86FastISel.cpp

Issue 7539010: Emit immediate call arguments locally to save stack size when compiling with -O0 (Closed) Base URL: http://llvm.org/svn/llvm-project/llvm/trunk/
Patch Set: Remove an empty line Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===-- X86FastISel.cpp - X86 FastISel implementation ---------------------===// 1 //===-- X86FastISel.cpp - X86 FastISel implementation ---------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file defines the X86-specific support for the FastISel class. Much 10 // This file defines the X86-specific support for the FastISel class. Much
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 Flags.setByValAlign(FrameAlign); 1558 Flags.setByValAlign(FrameAlign);
1559 if (!IsMemcpySmall(FrameSize)) 1559 if (!IsMemcpySmall(FrameSize))
1560 return false; 1560 return false;
1561 } 1561 }
1562 1562
1563 if (CS.paramHasAttr(AttrInd, Attribute::InReg)) 1563 if (CS.paramHasAttr(AttrInd, Attribute::InReg))
1564 Flags.setInReg(); 1564 Flags.setInReg();
1565 if (CS.paramHasAttr(AttrInd, Attribute::Nest)) 1565 if (CS.paramHasAttr(AttrInd, Attribute::Nest))
1566 Flags.setNest(); 1566 Flags.setNest();
1567 1567
1568 // If this is an i1/i8/i16 argument, promote to i32 to avoid an extra 1568 unsigned ArgReg;
1569 // instruction. This is safe because it is common to all fastisel supported 1569 MVT ArgVT;
1570 // calling conventions on x86.
1571 if (ConstantInt *CI = dyn_cast<ConstantInt>(ArgVal)) { 1570 if (ConstantInt *CI = dyn_cast<ConstantInt>(ArgVal)) {
1571 // If this is an i1/i8/i16 argument, promote to i32 to avoid an extra
1572 // instruction. This is safe because it is common to all fastisel
1573 // supported calling conventions on x86.
1572 if (CI->getBitWidth() == 1 || CI->getBitWidth() == 8 || 1574 if (CI->getBitWidth() == 1 || CI->getBitWidth() == 8 ||
1573 CI->getBitWidth() == 16) { 1575 CI->getBitWidth() == 16) {
1574 if (Flags.isSExt()) 1576 if (Flags.isSExt())
1575 ArgVal = ConstantExpr::getSExt(CI,Type::getInt32Ty(CI->getContext())); 1577 ArgVal = ConstantExpr::getSExt(CI,Type::getInt32Ty(CI->getContext()));
1576 else 1578 else
1577 ArgVal = ConstantExpr::getZExt(CI,Type::getInt32Ty(CI->getContext())); 1579 ArgVal = ConstantExpr::getZExt(CI,Type::getInt32Ty(CI->getContext()));
1578 } 1580 }
1579 }
1580 1581
1581 unsigned ArgReg; 1582 // Emit immediate arguments for the call locally to avoid spilling.
1582 1583 if (!isTypeLegal(ArgVal->getType(), ArgVT)) return false;
1584 uint64_t val;
1585 if (Flags.isSExt())
1586 val = CI->getSExtValue();
1587 else
1588 val = CI->getZExtValue();
1589 ArgReg = FastEmit_i(ArgVT, ArgVT, ISD::Constant, val);
1590 // ArgReg = getRegForValue(ArgVal);
nlewycky 2011/08/01 20:49:28 Don't send out a patch with a commented-out line.
krasin 2011/08/01 20:55:37 Shame on me! Done.
1583 // Passing bools around ends up doing a trunc to i1 and passing it. 1591 // Passing bools around ends up doing a trunc to i1 and passing it.
1584 // Codegen this as an argument + "and 1". 1592 // Codegen this as an argument + "and 1".
1585 if (ArgVal->getType()->isIntegerTy(1) && isa<TruncInst>(ArgVal) && 1593 } else if (ArgVal->getType()->isIntegerTy(1) && isa<TruncInst>(ArgVal) &&
1586 cast<TruncInst>(ArgVal)->getParent() == I->getParent() && 1594 cast<TruncInst>(ArgVal)->getParent() == I->getParent() &&
1587 ArgVal->hasOneUse()) { 1595 ArgVal->hasOneUse()) {
1588 ArgVal = cast<TruncInst>(ArgVal)->getOperand(0); 1596 ArgVal = cast<TruncInst>(ArgVal)->getOperand(0);
1589 ArgReg = getRegForValue(ArgVal); 1597 ArgReg = getRegForValue(ArgVal);
1590 if (ArgReg == 0) return false; 1598 if (ArgReg == 0) return false;
1591 1599
1592 MVT ArgVT;
1593 if (!isTypeLegal(ArgVal->getType(), ArgVT)) return false; 1600 if (!isTypeLegal(ArgVal->getType(), ArgVT)) return false;
1594 1601
1595 ArgReg = FastEmit_ri(ArgVT, ArgVT, ISD::AND, ArgReg, 1602 ArgReg = FastEmit_ri(ArgVT, ArgVT, ISD::AND, ArgReg,
1596 ArgVal->hasOneUse(), 1); 1603 ArgVal->hasOneUse(), 1);
1597 } else { 1604 } else {
1598 ArgReg = getRegForValue(ArgVal); 1605 ArgReg = getRegForValue(ArgVal);
1599 } 1606 }
1600 1607
1601 if (ArgReg == 0) return false; 1608 if (ArgReg == 0) return false;
1602 1609
1603 Type *ArgTy = ArgVal->getType(); 1610 Type *ArgTy = ArgVal->getType();
1604 MVT ArgVT;
1605 if (!isTypeLegal(ArgTy, ArgVT)) 1611 if (!isTypeLegal(ArgTy, ArgVT))
1606 return false; 1612 return false;
1607 if (ArgVT == MVT::x86mmx) 1613 if (ArgVT == MVT::x86mmx)
1608 return false; 1614 return false;
1609 unsigned OriginalAlignment = TD.getABITypeAlignment(ArgTy); 1615 unsigned OriginalAlignment = TD.getABITypeAlignment(ArgTy);
1610 Flags.setOrigAlign(OriginalAlignment); 1616 Flags.setOrigAlign(OriginalAlignment);
1611 1617
1612 Args.push_back(ArgReg); 1618 Args.push_back(ArgReg);
1613 ArgVals.push_back(ArgVal); 1619 ArgVals.push_back(ArgVal);
1614 ArgVTs.push_back(ArgVT); 1620 ArgVTs.push_back(ArgVT);
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 MI->eraseFromParent(); 2130 MI->eraseFromParent();
2125 return true; 2131 return true;
2126 } 2132 }
2127 2133
2128 2134
2129 namespace llvm { 2135 namespace llvm {
2130 llvm::FastISel *X86::createFastISel(FunctionLoweringInfo &funcInfo) { 2136 llvm::FastISel *X86::createFastISel(FunctionLoweringInfo &funcInfo) {
2131 return new X86FastISel(funcInfo); 2137 return new X86FastISel(funcInfo);
2132 } 2138 }
2133 } 2139 }
OLDNEW
« no previous file with comments | « no previous file | test/CodeGen/X86/fast-isel-call-x86-64.ll » ('j') | test/CodeGen/X86/fast-isel-call-x86-64.ll » ('J')

Powered by Google App Engine
This is Rietveld 408576698