Add support for 1-wide scalar target.

Issue #40.
This commit is contained in:
Gabe Weisz
2012-01-28 15:31:42 -05:00
committed by Matt Pharr
parent c96fef6bc8
commit c67a286aa6
5 changed files with 1025 additions and 4 deletions

View File

@@ -72,7 +72,7 @@ CXX_SRC=ast.cpp builtins.cpp cbackend.cpp ctx.cpp decl.cpp expr.cpp func.cpp \
HEADERS=ast.h builtins.h ctx.h decl.h expr.h func.h ispc.h llvmutil.h module.h \ HEADERS=ast.h builtins.h ctx.h decl.h expr.h func.h ispc.h llvmutil.h module.h \
opt.h stmt.h sym.h type.h util.h opt.h stmt.h sym.h type.h util.h
TARGETS=avx1 avx1-x2 avx2 avx2-x2 sse2 sse2-x2 sse4 sse4-x2 generic-4 generic-8 \ TARGETS=avx1 avx1-x2 avx2 avx2-x2 sse2 sse2-x2 sse4 sse4-x2 generic-4 generic-8 \
generic-16 generic-16 generic-1
BUILTINS_SRC=$(addprefix builtins/target-, $(addsuffix .ll, $(TARGETS))) \ BUILTINS_SRC=$(addprefix builtins/target-, $(addsuffix .ll, $(TARGETS))) \
builtins/dispatch.ll builtins/dispatch.ll
BUILTINS_OBJS=$(addprefix builtins-, $(notdir $(BUILTINS_SRC:.ll=.o))) \ BUILTINS_OBJS=$(addprefix builtins-, $(notdir $(BUILTINS_SRC:.ll=.o))) \

View File

@@ -799,6 +799,13 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod
builtins_bitcode_generic_16_length, builtins_bitcode_generic_16_length,
module, symbolTable); module, symbolTable);
break; break;
case 1:
extern unsigned char builtins_bitcode_generic_1[];
extern int builtins_bitcode_generic_1_length;
AddBitcodeToModule(builtins_bitcode_generic_1,
builtins_bitcode_generic_1_length,
module, symbolTable);
break;
default: default:
FATAL("logic error in DefineStdlib"); FATAL("logic error in DefineStdlib");
} }
@@ -834,7 +841,7 @@ DefineStdlib(SymbolTable *symbolTable, llvm::LLVMContext *ctx, llvm::Module *mod
// If the user wants the standard library to be included, parse the // If the user wants the standard library to be included, parse the
// serialized version of the stdlib.ispc file to get its // serialized version of the stdlib.ispc file to get its
// definitions added. // definitions added.
if (g->target.isa == Target::GENERIC) { if (g->target.isa == Target::GENERIC&&g->target.vectorWidth!=1) { // 1 wide uses x86 stdlib
extern char stdlib_generic_code[]; extern char stdlib_generic_code[];
yy_scan_string(stdlib_generic_code); yy_scan_string(stdlib_generic_code);
yyparse(); yyparse();

1006
builtins/target-generic-1.ll Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -185,6 +185,14 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->allOffMaskIsSafe = true; t->allOffMaskIsSafe = true;
t->maskBitCount = 1; t->maskBitCount = 1;
} }
else if (!strcasecmp(isa, "generic-1")) {
t->isa = Target::GENERIC;
t->nativeVectorWidth = 1;
t->vectorWidth = 1;
t->maskingIsFree = false;
t->allOffMaskIsSafe = false;
t->maskBitCount = 32;
}
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) #if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
else if (!strcasecmp(isa, "avx")) { else if (!strcasecmp(isa, "avx")) {
t->isa = Target::AVX; t->isa = Target::AVX;
@@ -270,7 +278,7 @@ Target::SupportedTargetISAs() {
#ifdef LLVM_3_1svn #ifdef LLVM_3_1svn
", avx2, avx2-x2" ", avx2, avx2-x2"
#endif // LLVM_3_1svn #endif // LLVM_3_1svn
", generic-4, generic-8, generic-16"; ", generic-4, generic-8, generic-16, generic-1";
} }

View File

@@ -1659,7 +1659,7 @@ lAddFunctionParams(Declarator *decl) {
/** Add a symbol for the built-in mask variable to the symbol table */ /** Add a symbol for the built-in mask variable to the symbol table */
static void lAddMaskToSymbolTable(SourcePos pos) { static void lAddMaskToSymbolTable(SourcePos pos) {
const Type *t = g->target.isa == Target::GENERIC ? const Type *t = g->target.maskBitCount == 1 ?
AtomicType::VaryingConstBool : AtomicType::VaryingConstUInt32; AtomicType::VaryingConstBool : AtomicType::VaryingConstUInt32;
Symbol *maskSymbol = new Symbol("__mask", pos, t); Symbol *maskSymbol = new Symbol("__mask", pos, t);
m->symbolTable->AddVariable(maskSymbol); m->symbolTable->AddVariable(maskSymbol);