diff --git a/cbackend.cpp b/cbackend.cpp index 3ae9f5e0..b800d4ac 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -778,6 +778,16 @@ raw_ostream &CWriter::printType(raw_ostream &Out, Type *Ty, Out << " return ret;\n"; Out << " }\n "; + // if it's an array of i8s, also provide a version that takes a const + // char * + if (ATy->getElementType() == LLVMTypes::Int8Type) { + Out << " static " << NameSoFar << " init(const char *p) {\n"; + Out << " " << NameSoFar << " ret;\n"; + Out << " strncpy((char *)ret.array, p, " << NumElements << ");\n"; + Out << " return ret;\n"; + Out << " }\n"; + } + printType(Out, ATy->getElementType(), false, "array[" + utostr(NumElements) + "]"); return Out << ";\n} "; @@ -1330,7 +1340,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) { case Type::ArrayTyID: { ArrayType *AT = cast(CPV->getType()); - if (Static || !isa(AT->getElementType())) + if (Static) // arrays are wrapped in structs... Out << "{ "; else { @@ -1352,7 +1362,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) { } } } - if (Static || !isa(AT->getElementType())) + if (Static) Out << " }"; else Out << ")"; diff --git a/ispc.cpp b/ispc.cpp index 85f81b3c..523927fc 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -387,7 +387,6 @@ lGenericTypeLayoutIndeterminate(LLVM_TYPE_CONST llvm::Type *type) { return false; } - type->dump(); Assert(llvm::isa(type)); return true; }