summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm2cpp/CppWriter.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-11 09:54:08 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-11 09:54:08 +0000
commit3318579108b9c230c86117128bbd52b1306d19f4 (patch)
tree6d5e6862139317d9837b9f3cfe504fadbe53828b /llvm/tools/llvm2cpp/CppWriter.cpp
parent81f14c63da751416ee01d818d578ea570fb04bf7 (diff)
downloadbcm5719-llvm-3318579108b9c230c86117128bbd52b1306d19f4.tar.gz
bcm5719-llvm-3318579108b9c230c86117128bbd52b1306d19f4.zip
Add support for parameter attributes.
llvm-svn: 35893
Diffstat (limited to 'llvm/tools/llvm2cpp/CppWriter.cpp')
-rw-r--r--llvm/tools/llvm2cpp/CppWriter.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/llvm/tools/llvm2cpp/CppWriter.cpp b/llvm/tools/llvm2cpp/CppWriter.cpp
index fb87b902c85..a2f02c3f202 100644
--- a/llvm/tools/llvm2cpp/CppWriter.cpp
+++ b/llvm/tools/llvm2cpp/CppWriter.cpp
@@ -18,6 +18,7 @@
#include "llvm/InlineAsm.h"
#include "llvm/Instruction.h"
#include "llvm/Instructions.h"
+#include "llvm/ParameterAttributes.h"
#include "llvm/Module.h"
#include "llvm/TypeSymbolTable.h"
#include "llvm/ADT/StringExtras.h"
@@ -457,6 +458,29 @@ CppWriter::printTypeInternal(const Type* Ty) {
Out << ");";
nl(Out);
}
+ const ParamAttrsList *PAL = FT->getParamAttrs();
+ Out << "ParamAttrsList *" << typeName << "_PAL = 0;";
+ if (PAL && !PAL->empty()) {
+ Out << typeName << "_PAL = new ParamAttrsList();";
+ for (unsigned i = 0; i < PAL->size(); ++i) {
+ uint16_t index = PAL->getParamIndex(i);
+ uint16_t attrs = PAL->getParamAttrs(index);
+ Out << typeName << "_PAL->addAttribute(" << index << ", 0";
+ if (attrs & ParamAttr::SExt)
+ Out << " | ParamAttr::SExt";
+ if (attrs & ParamAttr::ZExt)
+ Out << " | ParamAttr::ZExt";
+ if (attrs & ParamAttr::StructRet)
+ Out << " | ParamAttr::StructRet";
+ if (attrs & ParamAttr::InReg)
+ Out << " | ParamAttr::InReg";
+ if (attrs & ParamAttr::NoReturn)
+ Out << " | ParamAttr::NoReturn";
+ if (attrs & ParamAttr::NoUnwind)
+ Out << " | ParamAttr::NoUnwind";
+ Out << ");";
+ }
+ }
bool isForward = printTypeInternal(FT->getReturnType());
std::string retTypeName(getCppName(FT->getReturnType()));
Out << "FunctionType* " << typeName << " = FunctionType::get(";
@@ -465,7 +489,8 @@ CppWriter::printTypeInternal(const Type* Ty) {
Out << "_fwd";
Out << ",";
nl(Out) << "/*Params=*/" << typeName << "_args,";
- nl(Out) << "/*isVarArg=*/" << (FT->isVarArg() ? "true" : "false") << ");";
+ nl(Out) << "/*isVarArg=*/" << (FT->isVarArg() ? "true" : "false") ;
+ nl(Out) << "/*ParamAttrs=/" << typeName << "_PAL" << ");";
out();
nl(Out);
break;
OpenPOWER on IntegriCloud