Mercurial > projects > ldc
view tests/mini/intrinsics.d @ 988:2667e3a145be
- Fixed LLVM style CL args for D2.
- Moved main() into its own file gen/main.cpp
- Fixed basic cross compilation
- removed the option for setting OS
- added support for llc's mattr, mcpu and mtriple switches
- added basic ABI abstraction for return value rewrites, it's not perfect and will probably be completely rewritten once I get to handling parameter rewrites as well.
- x86-64 extern(C) abi for cfloat returns now match (llvm-)gcc.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Thu, 26 Feb 2009 14:11:49 +0100 |
parents | 4ac97ec7c18e |
children | 146d8dfa0043 |
line wrap: on
line source
import ldc.intrinsics; extern(C) int printf(char*,...); extern(C) int scanf(char*,...); void main() { float f; printf("Enter float: "); //scanf("%f", &f); f = 1.22345; float sf = llvm_sqrt_f32(f); printf("sqrt(%f) = %f\n", f, sf); double d; printf("Enter double: "); //scanf("%lf", &d); d = 2.2311167895435245; double sd = llvm_sqrt_f64(d); printf("sqrt(%lf) = %lf\n", d, sd); real r; printf("Enter real: "); //scanf("%llf", &r); r = 3.2311167891231231234754764576; version(X86) { real sr = llvm_sqrt_f80(r); printf("sqrt(%llf) = %llf\n", r, sr); } else version (X86_64) { real sr = llvm_sqrt_f80(r); printf("sqrt(%llf) = %llf\n", r, sr); } else { real sr = llvm_sqrt_f64(r); printf("sqrt(%f) = %lf\n", r, sr); } }