Add Symbol::exportedFunction member to hold llvm::Function * for app-callable version of function.
This commit is contained in:
@@ -497,7 +497,6 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLVM_TYPE_CONST llvm::Type *llvmType = decl->sym->type->LLVMType(g->ctx);
|
LLVM_TYPE_CONST llvm::Type *llvmType = decl->sym->type->LLVMType(g->ctx);
|
||||||
llvm::GlobalValue::LinkageTypes linkage =
|
|
||||||
(ds->storageClass == SC_STATIC) ? llvm::GlobalValue::InternalLinkage :
|
(ds->storageClass == SC_STATIC) ? llvm::GlobalValue::InternalLinkage :
|
||||||
llvm::GlobalValue::ExternalLinkage;
|
llvm::GlobalValue::ExternalLinkage;
|
||||||
|
|
||||||
@@ -551,6 +550,9 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isConst = (ds->typeQualifier & TYPEQUAL_CONST) != 0;
|
bool isConst = (ds->typeQualifier & TYPEQUAL_CONST) != 0;
|
||||||
|
llvm::GlobalValue::LinkageTypes linkage =
|
||||||
|
(ds->storageClass == SC_STATIC) ? llvm::GlobalValue::InternalLinkage :
|
||||||
|
llvm::GlobalValue::ExternalLinkage;
|
||||||
decl->sym->storagePtr = new llvm::GlobalVariable(*module, llvmType, isConst,
|
decl->sym->storagePtr = new llvm::GlobalVariable(*module, llvmType, isConst,
|
||||||
linkage, llvmInitializer,
|
linkage, llvmInitializer,
|
||||||
decl->sym->name.c_str());
|
decl->sym->name.c_str());
|
||||||
@@ -843,6 +845,7 @@ Module::AddFunction(DeclSpecs *ds, Declarator *decl, Stmt *code) {
|
|||||||
firstStmtPos);
|
firstStmtPos);
|
||||||
lEmitFunctionCode(&ec, appFunction, functionType, funSym, decl, code);
|
lEmitFunctionCode(&ec, appFunction, functionType, funSym, decl, code);
|
||||||
if (errorCount == 0) {
|
if (errorCount == 0) {
|
||||||
|
funSym->exportedFunction = appFunction;
|
||||||
if (llvm::verifyFunction(*appFunction,
|
if (llvm::verifyFunction(*appFunction,
|
||||||
llvm::ReturnStatusAction) == true) {
|
llvm::ReturnStatusAction) == true) {
|
||||||
if (g->debugPrint) {
|
if (g->debugPrint) {
|
||||||
|
|||||||
2
sym.cpp
2
sym.cpp
@@ -47,7 +47,7 @@ Symbol::Symbol(const std::string &n, SourcePos p, const Type *t,
|
|||||||
StorageClass sc)
|
StorageClass sc)
|
||||||
: pos(p), name(n) {
|
: pos(p), name(n) {
|
||||||
storagePtr = NULL;
|
storagePtr = NULL;
|
||||||
function = NULL;
|
function = exportedFunction = NULL;
|
||||||
type = t;
|
type = t;
|
||||||
constValue = NULL;
|
constValue = NULL;
|
||||||
storageClass = sc;
|
storageClass = sc;
|
||||||
|
|||||||
5
sym.h
5
sym.h
@@ -83,6 +83,11 @@ public:
|
|||||||
llvm::Function *function; /*!< For symbols that represent functions,
|
llvm::Function *function; /*!< For symbols that represent functions,
|
||||||
this stores the LLVM Function value for
|
this stores the LLVM Function value for
|
||||||
the symbol once it has been created. */
|
the symbol once it has been created. */
|
||||||
|
llvm::Function *exportedFunction;
|
||||||
|
/*!< For symbols that represent functions with
|
||||||
|
'export' qualifiers, this points to the LLVM
|
||||||
|
Function for the application-callable version
|
||||||
|
of the function. */
|
||||||
const Type *type; /*!< The type of the symbol; if not set by the
|
const Type *type; /*!< The type of the symbol; if not set by the
|
||||||
constructor, this is set after the
|
constructor, this is set after the
|
||||||
declaration around the symbol has been parsed. */
|
declaration around the symbol has been parsed. */
|
||||||
|
|||||||
Reference in New Issue
Block a user