Skip to content

Commit

Permalink
[gh-198] Always internalise basic arithmetical/relational functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhrr committed Oct 7, 2018
1 parent 61acb31 commit 7e63a0b
Show file tree
Hide file tree
Showing 3 changed files with 343 additions and 0 deletions.
326 changes: 326 additions & 0 deletions src/dale/BasicTypes/BasicTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,332 @@

namespace dale {
namespace BasicTypes {
std::vector<std::string> basic_type_form_strings;
void initBasicTypeFormStrings(void) {
const char *basic_type_form_strings_cc[317] = {
"_Z1$2bii",
"_Z1$2dii",
"_Z1$2fii",
"_Z1$2aii",
"_Z1$25ii",
"_Z1$26ii",
"_Z1$7cii",
"_Z1$5eii",
"_Z1$3dii",
"_Z2$21$3dii",
"_Z1$3cii",
"_Z2$3c$3dii",
"_Z1$3eii",
"_Z2$3e$3dii",
"_Z2$3c$3cii",
"_Z2$3e$3eii",
"_Z1$2di",
"_Z1$2bcc",
"_Z1$2dcc",
"_Z1$2fcc",
"_Z1$2acc",
"_Z1$25cc",
"_Z1$26cc",
"_Z1$7ccc",
"_Z1$5ecc",
"_Z1$3dcc",
"_Z2$21$3dcc",
"_Z1$3ccc",
"_Z2$3c$3dcc",
"_Z1$3ecc",
"_Z2$3e$3dcc",
"_Z2$3c$3cci",
"_Z2$3e$3eci",
"_Z1$2dc",
"_Z1$2byy",
"_Z1$2dyy",
"_Z1$2fyy",
"_Z1$2ayy",
"_Z1$25yy",
"_Z1$26yy",
"_Z1$7cyy",
"_Z1$5eyy",
"_Z1$3dyy",
"_Z2$21$3dyy",
"_Z1$3cyy",
"_Z2$3c$3dyy",
"_Z1$3eyy",
"_Z2$3e$3dyy",
"_Z2$3c$3cyi",
"_Z2$3e$3eyi",
"_Z1$2dy",
"_Z1$2bnn",
"_Z1$2dnn",
"_Z1$2fnn",
"_Z1$2ann",
"_Z1$25nn",
"_Z1$26nn",
"_Z1$7cnn",
"_Z1$5enn",
"_Z1$3dnn",
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aa",
"_Z2$3e$3daa",
"_Z1$2da",
};
for (int i = 0; i < 317; i++) {
basic_type_form_strings.push_back(basic_type_form_strings_cc[i]);
}
}

Function *addSimpleFunction(Context *ctx, llvm::Module *mod,
std::string *once_tag, const char *name,
int linkage, std::string *symbol_name,
Expand Down
6 changes: 6 additions & 0 deletions src/dale/BasicTypes/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ namespace dale {
numbers.
*/
namespace BasicTypes {
extern std::vector<std::string> basic_type_form_strings;

/*! Initialise the basic type form string array.
*/
void initBasicTypeFormStrings(void);

/*! Add a unary function to the context and module.
* @param ctx The context.
* @param mod The LLVM module.
Expand Down
11 changes: 11 additions & 0 deletions src/dale/Generator/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#include "../Unit/Unit.h"
#include "../Units/Units.h"
#include "../Utils/Utils.h"
#include "../BasicTypes/BasicTypes.h"

extern "C" {
void init_introspection_functions();
Expand Down Expand Up @@ -382,6 +383,16 @@ int Generator::run(std::vector<const char *> *file_paths,
if (remove_macros) {
ctx->eraseLLVMMacrosAndCTOFunctions();
}
dale::BasicTypes::initBasicTypeFormStrings();
for (std::vector<std::string>::iterator
b = dale::BasicTypes::basic_type_form_strings.begin(),
e = dale::BasicTypes::basic_type_form_strings.end();
b != e;
++b) {
llvm::Function *fn =
mod->getFunction(*b);
fn->setLinkage(ctx->toLLVMLinkage(Linkage::Intern));
}
if (lto) {
for (llvm::Module::iterator b = mod->begin(),
e = mod->end();
Expand Down

0 comments on commit 7e63a0b

Please sign in to comment.