driver/gen/ir: clang-format the world

This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
This commit is contained in:
David Nadlinger 2015-11-01 22:09:44 +02:00
parent 123666cf89
commit 44b0f7b615
125 changed files with 28991 additions and 30602 deletions

View file

@ -29,60 +29,52 @@ int Target::c_longsize;
int Target::c_long_doublesize;
bool Target::reverseCppOverloads;
void Target::init()
{
ptrsize = gDataLayout->getPointerSize(ADDRESS_SPACE);
void Target::init() {
ptrsize = gDataLayout->getPointerSize(ADDRESS_SPACE);
llvm::Type* real = DtoType(Type::basic[Tfloat80]);
realsize = gDataLayout->getTypeAllocSize(real);
realpad = realsize - gDataLayout->getTypeStoreSize(real);
realalignsize = gDataLayout->getABITypeAlignment(real);
c_longsize = global.params.is64bit ? 8 : 4;
c_long_doublesize = realsize;
llvm::Type *real = DtoType(Type::basic[Tfloat80]);
realsize = gDataLayout->getTypeAllocSize(real);
realpad = realsize - gDataLayout->getTypeStoreSize(real);
realalignsize = gDataLayout->getABITypeAlignment(real);
c_longsize = global.params.is64bit ? 8 : 4;
c_long_doublesize = realsize;
reverseCppOverloads = false; // DMC is not supported.
reverseCppOverloads = false; // DMC is not supported.
}
/******************************
* Return memory alignment size of type.
*/
unsigned Target::alignsize (Type* type)
{
assert (type->isTypeBasic());
if (type->ty == Tvoid) return 1;
return gDataLayout->getABITypeAlignment(DtoType(type));
unsigned Target::alignsize(Type *type) {
assert(type->isTypeBasic());
if (type->ty == Tvoid)
return 1;
return gDataLayout->getABITypeAlignment(DtoType(type));
}
/******************************
* Return field alignment size of type.
*/
unsigned Target::fieldalign (Type* type)
{
return DtoAlignment(type);
}
unsigned Target::fieldalign(Type *type) { return DtoAlignment(type); }
// sizes based on those from tollvm.cpp:DtoMutexType()
unsigned Target::critsecsize()
{
unsigned Target::critsecsize() {
#if defined(_MSC_VER)
// Return sizeof(RTL_CRITICAL_SECTION)
return global.params.is64bit ? 40 : 24;
// Return sizeof(RTL_CRITICAL_SECTION)
return global.params.is64bit ? 40 : 24;
#else
if (global.params.targetTriple.isOSWindows())
return global.params.is64bit ? 40 : 24;
else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD)
return sizeof(size_t);
else
return sizeof(pthread_mutex_t);
if (global.params.targetTriple.isOSWindows())
return global.params.is64bit ? 40 : 24;
else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD)
return sizeof(size_t);
else
return sizeof(pthread_mutex_t);
#endif
}
Type *Target::va_listType()
{
return gABI->vaListType();
}
Type *Target::va_listType() { return gABI->vaListType(); }
/******************************
* Encode the given expression, which is assumed to be an rvalue literal
@ -90,63 +82,59 @@ Type *Target::va_listType()
* This corresponds roughly to the idiom *(Type *)&e.
*/
Expression *Target::paintAsType(Expression *e, Type *type)
{
union
{
d_int32 int32value;
d_int64 int64value;
float float32value;
double float64value;
} u;
Expression *Target::paintAsType(Expression *e, Type *type) {
union {
d_int32 int32value;
d_int64 int64value;
float float32value;
double float64value;
} u;
assert(e->type->size() == type->size());
assert(e->type->size() == type->size());
switch (e->type->ty)
{
case Tint32:
case Tuns32:
u.int32value = (d_int32)e->toInteger();
break;
switch (e->type->ty) {
case Tint32:
case Tuns32:
u.int32value = (d_int32)e->toInteger();
break;
case Tint64:
case Tuns64:
u.int64value = (d_int64)e->toInteger();
break;
case Tint64:
case Tuns64:
u.int64value = (d_int64)e->toInteger();
break;
case Tfloat32:
u.float32value = e->toReal();
break;
case Tfloat32:
u.float32value = e->toReal();
break;
case Tfloat64:
u.float64value = e->toReal();
break;
case Tfloat64:
u.float64value = e->toReal();
break;
default:
assert(0);
}
default:
assert(0);
}
switch (type->ty)
{
case Tint32:
case Tuns32:
return new IntegerExp(e->loc, u.int32value, type);
switch (type->ty) {
case Tint32:
case Tuns32:
return new IntegerExp(e->loc, u.int32value, type);
case Tint64:
case Tuns64:
return new IntegerExp(e->loc, u.int64value, type);
case Tint64:
case Tuns64:
return new IntegerExp(e->loc, u.int64value, type);
case Tfloat32:
return new RealExp(e->loc, ldouble(u.float32value), type);
case Tfloat32:
return new RealExp(e->loc, ldouble(u.float32value), type);
case Tfloat64:
return new RealExp(e->loc, ldouble(u.float64value), type);
case Tfloat64:
return new RealExp(e->loc, ldouble(u.float64value), type);
default:
assert(0);
}
default:
assert(0);
}
return NULL; // avoid warning
return NULL; // avoid warning
}
/******************************
@ -157,10 +145,9 @@ Expression *Target::paintAsType(Expression *e, Type *type)
* 3: wrong base type
*/
int Target::checkVectorType(int sz, Type *type)
{
// FIXME: It is possible to query the LLVM target about supported vectors?
return 0;
int Target::checkVectorType(int sz, Type *type) {
// FIXME: It is possible to query the LLVM target about supported vectors?
return 0;
}
/******************************
@ -169,7 +156,4 @@ int Target::checkVectorType(int sz, Type *type)
* modules whose source are empty, but code gets injected
* immediately after loading.
*/
void Target::loadModule(Module *m)
{
}
void Target::loadModule(Module *m) {}