[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.

Branch statements now emit a new block after it.
Fixed the _adSort runtime function had a bad signature.
Added a missing dot prefix on compiler generated string tables for string switch.
Fixed, PTRSIZE seems like it was wrong on 64bit, now it definitely gets set properly.
This commit is contained in:
Tomas Lindquist Olsen
2008-06-16 16:01:19 +02:00
parent ccecb39c46
commit 964f91b5a1
83 changed files with 141 additions and 45 deletions

View File

@@ -223,16 +223,18 @@ void Type::init()
tvoidptr = tvoid->pointerTo();
// set size_t / ptrdiff_t types
// set size_t / ptrdiff_t types and pointer size
if (global.params.is64bit)
{
Tsize_t = Tuns64;
Tptrdiff_t = Tint64;
PTRSIZE = 8;
}
else
{
Tsize_t = Tuns32;
Tptrdiff_t = Tint32;
PTRSIZE = 4;
}
// set real size and padding

View File

@@ -440,19 +440,26 @@ void BreakStatement::toIR(IRState* p)
targetLoopStatement = tmp->statement;
// find the right break block and jump there
bool found = false;
IRState::LoopScopeVec::reverse_iterator it;
for(it = p->loopbbs.rbegin(); it != p->loopbbs.rend(); ++it) {
if(it->s == targetLoopStatement) {
llvm::BranchInst::Create(it->end, p->scopebb());
return;
found = true;
break;
}
}
assert(0);
assert(found);
}
else {
emit_finallyblocks(p, enclosingtryfinally, p->loopbbs.back().enclosingtryfinally);
llvm::BranchInst::Create(p->loopbbs.back().end, p->scopebb());
}
// the break terminated this basicblock, start a new one
llvm::BasicBlock* oldend = gIR->scopeend();
llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterbreak", p->topfunc(), oldend);
p->scope() = IRScope(bb,oldend);
}
//////////////////////////////////////////////////////////////////////////////
@@ -724,7 +731,7 @@ void SwitchStatement::toIR(IRState* p)
const LLType* elemTy = DtoType(condition->type);
const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size());
LLConstant* arrInit = llvm::ConstantArray::get(arrTy, inits);
llvm::GlobalVariable* arr = new llvm::GlobalVariable(arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, "string_switch_table_data", gIR->module);
llvm::GlobalVariable* arr = new llvm::GlobalVariable(arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, ".string_switch_table_data", gIR->module);
const LLType* elemPtrTy = getPtrToType(elemTy);
LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy);
@@ -739,7 +746,7 @@ void SwitchStatement::toIR(IRState* p)
sinits.push_back(arrPtr);
LLConstant* sInit = llvm::ConstantStruct::get(sTy, sinits);
switchTable = new llvm::GlobalVariable(sTy, true, llvm::GlobalValue::InternalLinkage, sInit, "string_switch_table", gIR->module);
switchTable = new llvm::GlobalVariable(sTy, true, llvm::GlobalValue::InternalLinkage, sInit, ".string_switch_table", gIR->module);
}
// body block

View File

@@ -47,7 +47,6 @@ private
{
void* llvm_frameaddress(uint level=0);
}
extern(C) int printf(char*, ...);
}
}
@@ -98,7 +97,11 @@ extern (C) void* rt_stackBottom()
*/
extern (C) void* rt_stackTop()
{
version( D_InlineAsm_X86 )
version(LLVMDC)
{
return llvm_frameaddress();
}
else version( D_InlineAsm_X86 )
{
asm
{
@@ -107,10 +110,6 @@ extern (C) void* rt_stackTop()
ret;
}
}
else version(LLVMDC)
{
return llvm_frameaddress();
}
else
{
static assert( false, "Architecture not supported." );

View File

@@ -30,14 +30,14 @@ extern (C) int cmp(void* p1, void* p2)
return tiglobal.compare(p1, p2);
}
extern (C) long _adSort(Array a, TypeInfo ti)
extern (C) Array _adSort(Array a, TypeInfo ti)
{
synchronized
{
tiglobal = ti;
tango.stdc.stdlib.qsort(a.ptr, a.length, cast(size_t)ti.tsize(), &cmp);
}
return *cast(long*)(&a);
return a;
}

View File

@@ -1,5 +1,7 @@
module a;
extern(C) int printf(char*, ...);
int i = 42;
void main()

View File

@@ -1,5 +1,8 @@
module aa3;
extern(C) int printf(char*, ...);
alias char[] string;
void main()
{
int[string] aa;

View File

@@ -1,5 +1,7 @@
module aa6;
extern(C) int printf(char*, ...);
void main()
{
int[int] aa;

View File

@@ -3,6 +3,8 @@ module alloca1;
pragma(LLVM_internal, "alloca")
void* alloca(uint);
extern(C) int printf(char*, ...);
void main()
{
int n = 16;

View File

@@ -1,5 +1,7 @@
module b;
extern(C) int printf(char*, ...);
struct S
{
int i;

View File

@@ -1,3 +1,6 @@
extern(C) int printf(char*, ...);
void main()
{
printf("Bitwise operations test\n");

View File

@@ -1,5 +1,6 @@
module bug10;
import std.stdio;
extern(C) int printf(char*, ...);
class C
{
char[] msg;

View File

@@ -2,5 +2,5 @@ module bug12;
void main()
{
const string name="y";
const char[] name="y";
}

View File

@@ -1,4 +1,5 @@
module bug20;
extern(C) int printf(char*, ...);
void func(void delegate() dg)
{

View File

@@ -1,4 +1,5 @@
module bug21;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module bug22;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,6 @@
module bug23;
extern(C) int printf(char*, ...);
void main()
{
int i;

View File

@@ -1,4 +1,5 @@
module bug24;
extern(C) int printf(char*, ...);
struct S
{

View File

@@ -1,4 +1,5 @@
module bug25;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module bug29;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module bug32;
extern(C) int printf(char*, ...);
struct S
{

View File

@@ -1,4 +1,5 @@
module bug50;
extern(C) int printf(char*, ...);
pragma(LLVM_internal, "notypeinfo")
struct S

View File

@@ -1,4 +1,5 @@
module bug55;
extern(C) int printf(char*, ...);
int atoi(char[] s) {
int i, fac=1;

View File

@@ -1,4 +1,6 @@
module bug60;
extern(C) int printf(char*, ...);
void func(T...)(T t)
{
foreach(v;t) {

View File

@@ -1,4 +1,5 @@
module bug61;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module bug62;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module bug63;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,5 +1,5 @@
module bug77;
import std.c.string;
import tango.stdc.string;
void main()
{
size_t len;

View File

@@ -1,4 +1,5 @@
module bug80;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,6 @@
module bug9;
extern(C) int printf(char*, ...);
struct rgb
{
ubyte[3] values;

View File

@@ -1,5 +1,5 @@
module calls1;
import std.stdarg;
import tango.core.Vararg;
void main()
{
{int a = byVal1(3);}

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
class C
{
int i;

View File

@@ -1,4 +1,5 @@
module classes11;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
class A
{
int i;

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
class A
{
int i = 42;

View File

@@ -1,4 +1,5 @@
module classes5;
extern(C) int printf(char*, ...);
struct S
{

View File

@@ -1,4 +1,5 @@
module classes6;
extern(C) int printf(char*, ...);
class C
{

View File

@@ -1,5 +1,7 @@
module classinfo1;
extern(C) int printf(char*, ...);
class NoPtrs
{
}

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
version=AndAnd;
version=OrOr;

View File

@@ -1,3 +1,6 @@
extern(C) int printf(char*, ...);
struct S
{
int i;

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
struct vec3
{
float x,y,z;

View File

@@ -1,5 +1,7 @@
module e;
extern(C) int printf(char*, ...);
struct C
{
float x=0,y=0;

View File

@@ -1,4 +1,5 @@
module floatcmp;
extern(C) int printf(char*, ...);
void eq()
{

View File

@@ -1,17 +1,17 @@
module foreach1;
import std.stdio;
extern(C) int printf(char*, ...);
void main()
{
static arr = [1,2,3,4,5];
writef("forward");
printf("forward");
foreach(v;arr) {
writef(' ',v);
printf(" %d",v);
}
writef("\nreverse");
printf("\nreverse");
foreach_reverse(v;arr) {
writef(' ',v);
printf(" %d",v);
}
writef("\n");
printf("\n");
}

View File

@@ -1,5 +1,5 @@
module foreach2;
extern(C) int printf(char*, ...);
void main()
{
static arr = [1.0, 2.0, 4.0, 8.0, 16.0];

View File

@@ -1,5 +1,5 @@
module foreach3;
extern(C) int printf(char*, ...);
void main()
{
static str = ['h','e','l','l','o'];

View File

@@ -1,5 +1,5 @@
module foreach4;
extern(C) int printf(char*, ...);
void main()
{
int[] arr = new int[4];

View File

@@ -1,5 +1,5 @@
module foreach5;
extern(C) int printf(char*, ...);
void main()
{
int[3] arr = [1,2,3];

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
int return_six()
{
return 6;

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
void main()
{
printf("Testing functions\n");

View File

@@ -1,5 +1,7 @@
module g;
extern(C) int printf(char*, ...);
void func(char[] str)
{
printf("%.*s\n", str.length, str.ptr);

View File

@@ -1,4 +1,5 @@
module globals1;
extern(C) int printf(char*, ...);
char[] gstr = "hello world";

View File

@@ -1,4 +1,5 @@
module innerclass1;
extern(C) int printf(char*, ...);
class Outer
{

View File

@@ -2,7 +2,7 @@ module mainargs1;
extern(C) int printf(char*,...);
void main(string[] args)
void main(char[][] args)
{
foreach(v; args)
{

View File

@@ -1,8 +1,5 @@
module moduleinfo1;
// has static this
import std.outofmemory;
static this()
{
}

View File

@@ -1,12 +1,14 @@
module moduleinfo2;
import std.stdio;
extern(C) int printf(char*, ...);
void main()
{
ModuleInfo[] mi = ModuleInfo.modules();
writefln("listing ",mi.length," modules");
printf("listing %u modules:\n");
foreach(m; mi)
{
writefln(" ",m.name);
printf(" %s\n", m.name.length, m.name.ptr);
}
assert(mi.length > 50);
}

View File

@@ -1,4 +1,5 @@
module multiarr4;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module nested5;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module nested6;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module nested7;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module nested8;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module nested9;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,3 +1,6 @@
extern(C) int printf(char*, ...);
int main()
{
char[16] s = void;

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
void main()
{
printf("Pointer arithmetic test\n");

View File

@@ -1,5 +1,5 @@
module scope1;
extern(C) int printf(char*, ...);
void main()
{
printf("1\n");

View File

@@ -1,5 +1,5 @@
module scope2;
extern(C) int printf(char*, ...);
void main()
{
scope(exit) printf("exit\n");

View File

@@ -1,5 +1,5 @@
module scope3;
extern(C) int printf(char*, ...);
void main()
{
int i;

View File

@@ -1,5 +1,7 @@
/* Eratosthenes Sieve prime number calculation. */
extern(C) int printf(char*, ...);
bool flags[8191];
int main()

View File

@@ -1,6 +1,6 @@
module sqrts;
import std.c.math;
import tango.stdc.math;
double sqrt(double d)
{

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
static this()
{
printf("static this\n");

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
void numbers()
{
bool[8] bools;

View File

@@ -1,5 +1,5 @@
module strings1;
extern(C) int printf(char*, ...);
void f(char[11] buffer)
{
printf("%.*s\n", buffer.length, buffer.ptr);

View File

@@ -1,4 +1,5 @@
module switch2;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module switch3;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,4 +1,5 @@
module typeinfo;
extern(C) int printf(char*, ...);
void main()
{

View File

@@ -1,5 +1,5 @@
module typeinfo7;
extern(C) int printf(char*, ...);
int func(long)
{
return 0;

View File

@@ -1,5 +1,5 @@
module typeinfo8;
extern(C) int printf(char*, ...);
struct S
{
void func()

View File

@@ -1,5 +1,7 @@
module unrolled;
extern(C) int printf(char*, ...);
void test(T...)(T t) {
foreach (value; t) {
printf("%d\n", value);

View File

@@ -1,3 +1,5 @@
extern(C) int printf(char*, ...);
struct V2D(T)
{
T x,y;

View File

@@ -1,6 +1,6 @@
module vararg1;
import std.c.stdarg;
import tango.stdc.stdarg;
extern(C) int add(int n, ...)
{

View File

@@ -1,6 +1,6 @@
module vararg3;
import std.stdarg;
import tango.core.Vararg;
void func(...)
{

View File

@@ -1,5 +1,5 @@
module vararg4;
import std.stdarg;
import tango.core.Vararg;
void vafunc(...)
{

View File

@@ -1,5 +1,5 @@
module vararg5;
import std.stdarg;
import tango.core.Vararg;
void func(...)
{
char[] str = va_arg!(char[])(_argptr);

View File

@@ -1,5 +1,7 @@
module virtcall;
extern(C) int printf(char*, ...);
class C
{
override char[] toString()