#include "llvm/DerivedTypes.h"
#include "llvm/ParameterAttributes.h"
#include "llvm/IntrinsicInst.h"
+#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/ManagedStatic.h"
#include "SymbolTableListTraitsImpl.h"
ParamAttrsList::getParamAttrsText(uint16_t Attrs) {
std::string Result;
if (Attrs & ParamAttr::ZExt)
- Result += "zext ";
+ Result += "zeroext ";
if (Attrs & ParamAttr::SExt)
- Result += "sext ";
+ Result += "signext ";
if (Attrs & ParamAttr::NoReturn)
Result += "noreturn ";
if (Attrs & ParamAttr::NoUnwind)
Result += "nounwind ";
if (Attrs & ParamAttr::InReg)
Result += "inreg ";
+ if (Attrs & ParamAttr::NoAlias)
+ Result += "noalias ";
if (Attrs & ParamAttr::StructRet)
Result += "sret ";
+ if (Attrs & ParamAttr::ByVal)
+ Result += "byval ";
+ if (Attrs & ParamAttr::Nest)
+ Result += "nest ";
return Result;
}
ParamAttrsList *
ParamAttrsList::get(const ParamAttrsVector &attrVec) {
assert(!attrVec.empty() && "Illegal to create empty ParamAttrsList");
+#ifndef NDEBUG
+ for (unsigned i = 1, e = attrVec.size(); i < e; ++i)
+ assert(attrVec[i-1].index < attrVec[i].index && "Misordered ParamAttrsList!");
+#endif
ParamAttrsList key(attrVec);
FoldingSetNodeID ID;
key.Profile(ID);
assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy)
&& "LLVM functions cannot return aggregate values!");
- // Create the arguments vector, all arguments start out unnamed.
- for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) {
- assert(Ty->getParamType(i) != Type::VoidTy &&
- "Cannot have void typed arguments!");
- ArgumentList.push_back(new Argument(Ty->getParamType(i)));
- }
-
+ // If the function has arguments, mark them as lazily built.
+ if (Ty->getNumParams())
+ SubclassData = 1; // Set the "has lazy arguments" bit.
+
// Make sure that we get added to a function
LeakDetector::addGarbageObject(this);
ParamAttrs->dropRef();
}
+void Function::BuildLazyArguments() const {
+ // Create the arguments vector, all arguments start out unnamed.
+ const FunctionType *FT = getFunctionType();
+ for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
+ assert(FT->getParamType(i) != Type::VoidTy &&
+ "Cannot have void typed arguments!");
+ ArgumentList.push_back(new Argument(FT->getParamType(i)));
+ }
+
+ // Clear the lazy arguments bit.
+ const_cast<Function*>(this)->SubclassData &= ~1;
+}
+
+size_t Function::arg_size() const {
+ return getFunctionType()->getNumParams();
+}
+bool Function::arg_empty() const {
+ return getFunctionType()->getNumParams() == 0;
+}
+
void Function::setParent(Module *parent) {
if (getParent())
LeakDetector::addGarbageObject(this);
std::string Result(Table[id]);
for (unsigned i = 0; i < numTys; ++i)
if (Tys[i])
- Result += "." + Tys[i]->getDescription();
+ Result += "." + MVT::getValueTypeString(MVT::getValueType(Tys[i]));
return Result;
}
const FunctionType *Intrinsic::getType(ID id, const Type **Tys,
- uint32_t numTys) {
+ unsigned numTys) {
const Type *ResultTy = NULL;
std::vector<const Type*> ArgTys;
bool IsVarArg = false;