Mercurial > projects > ldc
comparison gen/tollvm.cpp @ 445:cc40db549aea
Changed the handling of variadic intrinsics a bit.
Removed the -fp80 option and made real be 80bit floats on X86, this is what the D spec really says it should be and fixes a bunch of issues.
Changed the handling of parameter attributes to a bit more generalized approach.
Added sext/zext attributes for byte/short/ubyte/ushort parameters, fixes #60 .
Parameter attribs now properly set for intrinsic calls if necessary.
Made the tango.math.Math patch less intrusive.
Fixed/added some mini tests.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Fri, 01 Aug 2008 17:59:58 +0200 |
parents | ac1fcc138e42 |
children | e381e082d5cb |
comparison
equal
deleted
inserted
replaced
444:f2b5f86348ef | 445:cc40db549aea |
---|---|
31 bool DtoIsReturnedInArg(Type* type) | 31 bool DtoIsReturnedInArg(Type* type) |
32 { | 32 { |
33 Type* typ = DtoDType(type); | 33 Type* typ = DtoDType(type); |
34 TY t = typ->ty; | 34 TY t = typ->ty; |
35 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray || typ->iscomplex()); | 35 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray || typ->iscomplex()); |
36 } | |
37 | |
38 unsigned DtoShouldExtend(Type* type) | |
39 { | |
40 type = type->toBasetype(); | |
41 if (type->isintegral()) | |
42 { | |
43 switch(type->ty) | |
44 { | |
45 case Tint8: | |
46 case Tint16: | |
47 return llvm::ParamAttr::SExt; | |
48 | |
49 case Tuns8: | |
50 case Tuns16: | |
51 return llvm::ParamAttr::ZExt; | |
52 } | |
53 } | |
54 return llvm::ParamAttr::None; | |
36 } | 55 } |
37 | 56 |
38 Type* DtoDType(Type* t) | 57 Type* DtoDType(Type* t) |
39 { | 58 { |
40 if (t->ty == Ttypedef) { | 59 if (t->ty == Ttypedef) { |
77 case Tfloat64: | 96 case Tfloat64: |
78 case Timaginary64: | 97 case Timaginary64: |
79 return LLType::DoubleTy; | 98 return LLType::DoubleTy; |
80 case Tfloat80: | 99 case Tfloat80: |
81 case Timaginary80: | 100 case Timaginary80: |
82 return (global.params.useFP80) ? LLType::X86_FP80Ty : LLType::DoubleTy; | 101 if (global.params.cpu == ARCHx86) |
102 return LLType::X86_FP80Ty; | |
103 else | |
104 return LLType::DoubleTy; | |
83 | 105 |
84 // complex | 106 // complex |
85 case Tcomplex32: | 107 case Tcomplex32: |
86 case Tcomplex64: | 108 case Tcomplex64: |
87 case Tcomplex80: | 109 case Tcomplex80: |
483 return llvm::ConstantInt::get(LLType::Int8Ty, i, false); | 505 return llvm::ConstantInt::get(LLType::Int8Ty, i, false); |
484 } | 506 } |
485 | 507 |
486 llvm::ConstantFP* DtoConstFP(Type* t, long double value) | 508 llvm::ConstantFP* DtoConstFP(Type* t, long double value) |
487 { | 509 { |
488 TY ty = DtoDType(t)->ty; | 510 const LLType* llty = DtoType(t); |
489 if (ty == Tfloat32 || ty == Timaginary32) | 511 assert(llty->isFloatingPoint()); |
490 return llvm::ConstantFP::get(llvm::APFloat(float(value))); | 512 return LLConstantFP::get(llty, value); |
491 else if (ty == Tfloat64 || ty == Timaginary64 || ty == Tfloat80 || ty == Timaginary80) | |
492 return llvm::ConstantFP::get(llvm::APFloat(double(value))); | |
493 } | 513 } |
494 | 514 |
495 ////////////////////////////////////////////////////////////////////////////////////////// | 515 ////////////////////////////////////////////////////////////////////////////////////////// |
496 | 516 |
497 LLConstant* DtoConstString(const char* str) | 517 LLConstant* DtoConstString(const char* str) |