Mercurial > projects > ldc
comparison dmd/attrib.c @ 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 | 44f08170f4ef |
children | a34078905d01 |
comparison
equal
deleted
inserted
replaced
444:f2b5f86348ef | 445:cc40db549aea |
---|---|
829 #endif | 829 #endif |
830 | 830 |
831 // LLVMDC | 831 // LLVMDC |
832 #if IN_LLVM | 832 #if IN_LLVM |
833 | 833 |
834 // pragma(intrinsic, dotExpS) { funcdecl(s) } | 834 // pragma(intrinsic, string) { funcdecl(s) } |
835 else if (ident == Id::intrinsic) | 835 else if (ident == Id::intrinsic) |
836 { | 836 { |
837 Expression* expr = (Expression *)args->data[0]; | 837 Expression* expr = (Expression *)args->data[0]; |
838 expr = expr->semantic(sc); | 838 expr = expr->semantic(sc); |
839 if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) | 839 if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) |
842 fatal(); | 842 fatal(); |
843 } | 843 } |
844 llvm_internal = LLVMintrinsic; | 844 llvm_internal = LLVMintrinsic; |
845 } | 845 } |
846 | 846 |
847 // pragma(va_intrinsic, dotExpS) { funcdecl(s) } | |
848 else if (ident == Id::va_intrinsic) | |
849 { | |
850 Expression* expr = (Expression *)args->data[0]; | |
851 expr = expr->semantic(sc); | |
852 if (!args || args->dim != 1 || !parseStringExp(expr, arg1str)) | |
853 { | |
854 error("pragma va_intrinsic requires exactly 1 string literal parameter"); | |
855 fatal(); | |
856 } | |
857 llvm_internal = LLVMva_intrinsic; | |
858 } | |
859 | |
860 // pragma(notypeinfo) { typedecl(s) } | 847 // pragma(notypeinfo) { typedecl(s) } |
861 else if (ident == Id::no_typeinfo) | 848 else if (ident == Id::no_typeinfo) |
862 { | 849 { |
863 if (args && args->dim > 0) | 850 if (args && args->dim > 0) |
864 { | 851 { |
878 } | 865 } |
879 llvm_internal = LLVMno_moduleinfo; | 866 llvm_internal = LLVMno_moduleinfo; |
880 } | 867 } |
881 | 868 |
882 // pragma(alloca) { funcdecl(s) } | 869 // pragma(alloca) { funcdecl(s) } |
883 else if (ident == Id::alloca) | 870 else if (ident == Id::Alloca) |
884 { | 871 { |
885 if (args && args->dim > 0) | 872 if (args && args->dim > 0) |
886 { | 873 { |
887 error("pragma alloca takes no parameters"); | 874 error("pragma alloca takes no parameters"); |
888 fatal(); | 875 fatal(); |
889 } | 876 } |
890 llvm_internal = LLVMalloca; | 877 llvm_internal = LLVMalloca; |
891 } | 878 } |
892 | 879 |
893 // pragma(va_start) { templdecl(s) } | 880 // pragma(va_start) { templdecl(s) } |
894 else if (ident == Id::va_start) | 881 else if (ident == Id::vastart) |
895 { | 882 { |
896 if (args && args->dim > 0) | 883 if (args && args->dim > 0) |
897 { | 884 { |
898 error("pragma va_start takes no parameters"); | 885 error("pragma va_start takes no parameters"); |
899 fatal(); | 886 fatal(); |
900 } | 887 } |
901 llvm_internal = LLVMva_start; | 888 llvm_internal = LLVMva_start; |
902 } | 889 } |
903 | 890 |
891 // pragma(va_copy) { funcdecl(s) } | |
892 else if (ident == Id::vacopy) | |
893 { | |
894 if (args && args->dim > 0) | |
895 { | |
896 error("pragma va_copy takes no parameters"); | |
897 fatal(); | |
898 } | |
899 llvm_internal = LLVMva_copy; | |
900 } | |
901 | |
902 // pragma(va_end) { funcdecl(s) } | |
903 else if (ident == Id::vaend) | |
904 { | |
905 if (args && args->dim > 0) | |
906 { | |
907 error("pragma va_end takes no parameters"); | |
908 fatal(); | |
909 } | |
910 llvm_internal = LLVMva_end; | |
911 } | |
912 | |
904 // pragma(va_arg) { templdecl(s) } | 913 // pragma(va_arg) { templdecl(s) } |
905 else if (ident == Id::va_arg) | 914 else if (ident == Id::vaarg) |
906 { | 915 { |
907 if (args && args->dim > 0) | 916 if (args && args->dim > 0) |
908 { | 917 { |
909 error("pragma va_arg takes no parameters"); | 918 error("pragma va_arg takes no parameters"); |
910 fatal(); | 919 fatal(); |
957 | 966 |
958 if (llvm_internal) | 967 if (llvm_internal) |
959 { | 968 { |
960 if (s->llvmInternal) | 969 if (s->llvmInternal) |
961 { | 970 { |
962 error("multiple LLVMDC specific pragmas not allowed not affect the same declaration (%s at '%s')", s->toChars(), s->loc.toChars()); | 971 error("multiple LLVMDC specific pragmas not allowed not affect the same declaration ('%s' at '%s')", s->toChars(), s->loc.toChars()); |
963 fatal(); | 972 fatal(); |
964 } | 973 } |
965 switch(llvm_internal) | 974 switch(llvm_internal) |
966 { | 975 { |
967 case LLVMintrinsic: | 976 case LLVMintrinsic: |
968 case LLVMva_intrinsic: | |
969 if (FuncDeclaration* fd = s->isFuncDeclaration()) | 977 if (FuncDeclaration* fd = s->isFuncDeclaration()) |
970 { | 978 { |
971 fd->llvmInternal = llvm_internal; | 979 fd->llvmInternal = llvm_internal; |
972 fd->intrinsicName = arg1str; | 980 fd->intrinsicName = arg1str; |
973 } | 981 } |
974 else | 982 else |
975 { | 983 { |
976 error("intrinsic pragmas are only allowed to affect function declarations"); | 984 error("the intrinsic pragma is only allowed on function declarations"); |
977 fatal(); | 985 fatal(); |
978 } | 986 } |
979 break; | 987 break; |
980 | 988 |
981 case LLVMva_start: | 989 case LLVMva_start: |
982 case LLVMva_arg: | 990 case LLVMva_arg: |
983 if (TemplateDeclaration* td = s->isTemplateDeclaration()) | 991 if (TemplateDeclaration* td = s->isTemplateDeclaration()) |
984 { | 992 { |
985 if (td->parameters->dim != 1) | 993 if (td->parameters->dim != 1) |
986 { | 994 { |
987 error("the %s pragma template must have exactly one template parameter", ident->toChars()); | 995 error("the '%s' pragma template must have exactly one template parameter", ident->toChars()); |
988 fatal(); | 996 fatal(); |
989 } | 997 } |
990 else if (!td->onemember) | 998 else if (!td->onemember) |
991 { | 999 { |
992 error("the %s pragma template must have exactly one member", ident->toChars()); | 1000 error("the '%s' pragma template must have exactly one member", ident->toChars()); |
993 fatal(); | 1001 fatal(); |
994 } | 1002 } |
995 else if (td->overnext || td->overroot) | 1003 else if (td->overnext || td->overroot) |
996 { | 1004 { |
997 error("the %s pragma template must not be overloaded", ident->toChars()); | 1005 error("the '%s' pragma template must not be overloaded", ident->toChars()); |
998 fatal(); | 1006 fatal(); |
999 } | 1007 } |
1000 td->llvmInternal = llvm_internal; | 1008 td->llvmInternal = llvm_internal; |
1001 } | 1009 } |
1002 else | 1010 else |
1003 { | 1011 { |
1004 error("the %s pragma is only allowed on template declarations", ident->toChars()); | 1012 error("the '%s' pragma is only allowed on template declarations", ident->toChars()); |
1013 fatal(); | |
1014 } | |
1015 break; | |
1016 | |
1017 case LLVMva_copy: | |
1018 case LLVMva_end: | |
1019 if (FuncDeclaration* fd = s->isFuncDeclaration()) | |
1020 { | |
1021 fd->llvmInternal = llvm_internal; | |
1022 } | |
1023 else | |
1024 { | |
1025 error("the '%s' pragma is only allowed on function declarations", ident->toChars()); | |
1005 fatal(); | 1026 fatal(); |
1006 } | 1027 } |
1007 break; | 1028 break; |
1008 | 1029 |
1009 case LLVMno_typeinfo: | 1030 case LLVMno_typeinfo: |
1015 { | 1036 { |
1016 fd->llvmInternal = llvm_internal; | 1037 fd->llvmInternal = llvm_internal; |
1017 } | 1038 } |
1018 else | 1039 else |
1019 { | 1040 { |
1020 error("the %s pragma must only be used on function declarations of type 'void* function(uint nbytes)'", ident->toChars()); | 1041 error("the '%s' pragma must only be used on function declarations of type 'void* function(uint nbytes)'", ident->toChars()); |
1021 fatal(); | 1042 fatal(); |
1022 } | 1043 } |
1023 break; | 1044 break; |
1024 | 1045 |
1025 default: | 1046 default: |
1026 warning("LLVMDC specific pragma %s not yet implemented, ignoring", ident->toChars()); | 1047 warning("the LLVMDC specific pragma '%s' is not yet implemented, ignoring", ident->toChars()); |
1027 } | 1048 } |
1028 } | 1049 } |
1029 | 1050 |
1030 #endif // LLVMDC | 1051 #endif // LLVMDC |
1031 | 1052 |