Enable memory alignment management via compiler options
This commit is contained in:
@@ -996,6 +996,11 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod
|
||||
lDefineConstantInt("__have_native_transcendentals", g->target->hasTranscendentals(),
|
||||
module, symbolTable);
|
||||
|
||||
if (g->forceAlignment != -1) {
|
||||
llvm::GlobalVariable *alignment = module->getGlobalVariable("memory_alignment", true);
|
||||
alignment->setInitializer(LLVMInt32(g->forceAlignment));
|
||||
}
|
||||
|
||||
if (includeStdlibISPC) {
|
||||
// If the user wants the standard library to be included, parse the
|
||||
// serialized version of the stdlib.ispc file to get its
|
||||
|
||||
1
ispc.cpp
1
ispc.cpp
@@ -747,6 +747,7 @@ Globals::Globals() {
|
||||
if (getcwd(currentDirectory, sizeof(currentDirectory)) == NULL)
|
||||
FATAL("Current directory path too long!");
|
||||
#endif
|
||||
forceAlignment = -1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
4
ispc.h
4
ispc.h
@@ -551,6 +551,10 @@ struct Globals {
|
||||
/** Additional user-provided directories to search when processing
|
||||
#include directives in the preprocessor. */
|
||||
std::vector<std::string> includePath;
|
||||
|
||||
/** Indicates that alignment in memory allocation routines should be
|
||||
forced to have given value. -1 value means natural alignment for the platforms. */
|
||||
int forceAlignment;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
4
main.cpp
4
main.cpp
@@ -98,6 +98,7 @@ usage(int ret) {
|
||||
printf(" [--emit-c++]\t\t\tEmit a C++ source file as output\n");
|
||||
printf(" [--emit-llvm]\t\t\tEmit LLVM bitode file as output\n");
|
||||
printf(" [--emit-obj]\t\t\tGenerate object file file as output (default)\n");
|
||||
printf(" [--force-alignment=<value>]\t\tForce alignment in memory allocations routine to be <value>\n");
|
||||
printf(" [-g]\t\t\t\tGenerate debugging information\n");
|
||||
printf(" [--help]\t\t\t\tPrint help\n");
|
||||
printf(" [--help-dev]\t\t\tPrint help for developer options\n");
|
||||
@@ -393,6 +394,9 @@ int main(int Argc, char *Argv[]) {
|
||||
usage(1);
|
||||
}
|
||||
}
|
||||
else if (!strncmp(argv[i], "--force-alignment=", 18)) {
|
||||
g->forceAlignment = atoi(argv[i] + 18);
|
||||
}
|
||||
else if (!strcmp(argv[i], "--woff") || !strcmp(argv[i], "-woff")) {
|
||||
g->disableWarnings = true;
|
||||
g->emitPerfWarnings = false;
|
||||
|
||||
Reference in New Issue
Block a user