Mercurial > projects > ddmd
comparison dmd/codegen/Util.d @ 140:31c086f76669
dmd.lib now only contains the backend
backward references from the backend to the frontend are implemented in ddmd
win32_lib.mak is replaced by a patch
also fixed VisualD project file predefined versions
author | Trass3r |
---|---|
date | Tue, 14 Sep 2010 01:54:48 +0200 |
parents | af1bebfd96a4 |
children | af724d3510d7 |
comparison
equal
deleted
inserted
replaced
139:bc45b1c53019 | 140:31c086f76669 |
---|---|
53 import dmd.backend.Symbol; | 53 import dmd.backend.Symbol; |
54 import dmd.backend.Blockx; | 54 import dmd.backend.Blockx; |
55 import dmd.backend.RTLSYM; | 55 import dmd.backend.RTLSYM; |
56 import dmd.backend.block; | 56 import dmd.backend.block; |
57 import dmd.backend.LIST; | 57 import dmd.backend.LIST; |
58 import dmd.backend.iasm : binary; | |
58 | 59 |
59 import std.string; | 60 import std.string; |
60 import core.stdc.string; | 61 import core.stdc.string; |
61 import core.stdc.stdlib; | 62 import core.stdc.stdlib; |
62 | 63 |
650 /******************************************* | 651 /******************************************* |
651 * Convert intrinsic function to operator. | 652 * Convert intrinsic function to operator. |
652 * Returns that operator, -1 if not an intrinsic function. | 653 * Returns that operator, -1 if not an intrinsic function. |
653 */ | 654 */ |
654 | 655 |
655 extern (C++) extern int intrinsic_op(char* name); | 656 //extern (C++) extern int intrinsic_op(char* name); |
656 | 657 |
657 OPER intrinsic_oper(const(char)* name) | 658 OPER intrinsic_oper(const(char)* name) |
658 { | 659 { |
659 int result = intrinsic_op(cast(char*)name); | 660 version(DMDV1) |
660 if (result == -1) return OPER.OPMAX; | 661 static const(char) *namearray[] = |
661 return cast(OPER)result; | 662 [ |
663 "4math3cosFeZe", | |
664 "4math3sinFeZe", | |
665 "4math4fabsFeZe", | |
666 "4math4rintFeZe", | |
667 "4math4sqrtFdZd", | |
668 "4math4sqrtFeZe", | |
669 "4math4sqrtFfZf", | |
670 "4math4yl2xFeeZe", | |
671 "4math5ldexpFeiZe", | |
672 "4math6rndtolFeZl", | |
673 "4math6yl2xp1FeeZe", | |
674 | |
675 "9intrinsic2btFPkkZi", | |
676 "9intrinsic3bsfFkZi", | |
677 "9intrinsic3bsrFkZi", | |
678 "9intrinsic3btcFPkkZi", | |
679 "9intrinsic3btrFPkkZi", | |
680 "9intrinsic3btsFPkkZi", | |
681 "9intrinsic3inpFkZh", | |
682 "9intrinsic4inplFkZk", | |
683 "9intrinsic4inpwFkZt", | |
684 "9intrinsic4outpFkhZh", | |
685 "9intrinsic5bswapFkZk", | |
686 "9intrinsic5outplFkkZk", | |
687 "9intrinsic5outpwFktZt", | |
688 ]; | |
689 else | |
690 static const(char) *namearray[] = | |
691 [ | |
692 /* The names are mangled differently because of the pure and | |
693 * nothrow attributes. | |
694 */ | |
695 "4math3cosFNaNbNfeZe", | |
696 "4math3sinFNaNbNfeZe", | |
697 "4math4fabsFNaNbNfeZe", | |
698 "4math4rintFNaNbNfeZe", | |
699 "4math4sqrtFNaNbNfdZd", | |
700 "4math4sqrtFNaNbNfeZe", | |
701 "4math4sqrtFNaNbNffZf", | |
702 "4math4yl2xFNaNbNfeeZe", | |
703 "4math5ldexpFNaNbNfeiZe", | |
704 "4math6rndtolFNaNbNfeZl", | |
705 "4math6yl2xp1FNaNbNfeeZe", | |
706 | |
707 "9intrinsic2btFNaNbxPkkZi", | |
708 "9intrinsic3bsfFNaNbkZi", | |
709 "9intrinsic3bsrFNaNbkZi", | |
710 "9intrinsic3btcFNbPkkZi", | |
711 "9intrinsic3btrFNbPkkZi", | |
712 "9intrinsic3btsFNbPkkZi", | |
713 "9intrinsic3inpFNbkZh", | |
714 "9intrinsic4inplFNbkZk", | |
715 "9intrinsic4inpwFNbkZt", | |
716 "9intrinsic4outpFNbkhZh", | |
717 "9intrinsic5bswapFNaNbkZk", | |
718 "9intrinsic5outplFNbkkZk", | |
719 "9intrinsic5outpwFNbktZt", | |
720 ]; | |
721 | |
722 static const OPER ioptab[] = | |
723 [ | |
724 OPcos, | |
725 OPsin, | |
726 OPabs, | |
727 OPrint, | |
728 OPsqrt, | |
729 OPsqrt, | |
730 OPsqrt, | |
731 OPyl2x, | |
732 OPscale, | |
733 OPrndtol, | |
734 OPyl2xp1, | |
735 | |
736 OPbt, | |
737 OPbsf, | |
738 OPbsr, | |
739 OPbtc, | |
740 OPbtr, | |
741 OPbts, | |
742 OPinp, | |
743 OPinp, | |
744 OPinp, | |
745 OPoutp, | |
746 OPbswap, | |
747 OPoutp, | |
748 OPoutp, | |
749 ]; | |
750 | |
751 debug | |
752 { | |
753 assert(namearray.length == ioptab.length); | |
754 // assume sorted namearray | |
755 for (int i = 0; i < namearray.length - 1; i++) | |
756 { | |
757 if (strcmp(namearray[i], namearray[i + 1]) >= 0) | |
758 { | |
759 printf("namearray[%d] = '%s'\n", i, namearray[i]); | |
760 assert(0); | |
761 } | |
762 } | |
763 } | |
764 | |
765 size_t length = strlen(name); | |
766 if (length < 11 || !(name[7] == 'm' || name[7] == 'i') || name[0..6] != "_D3std") | |
767 return OPMAX; | |
768 | |
769 int p = binary(name + 6, namearray.ptr, namearray.length); | |
770 if(p == -1) | |
771 return OPMAX; | |
772 return ioptab[p]; | |
662 } | 773 } |
663 | 774 |
664 /************************************** | 775 /************************************** |
665 */ | 776 */ |
666 | 777 |
788 } | 899 } |
789 else if (t1.ty == TY.Tarray) | 900 else if (t1.ty == TY.Tarray) |
790 { | 901 { |
791 elength = *pe; | 902 elength = *pe; |
792 *pe = el_same(&elength); | 903 *pe = el_same(&elength); |
793 elength = el_una(OPER.OP64_32, TYM.TYuint, elength); | 904 elength = el_una(OP64_32, TYM.TYuint, elength); |
794 | 905 |
795 L3: | 906 L3: |
796 slength = lengthVar.toSymbol(); | 907 slength = lengthVar.toSymbol(); |
797 //symbol_add(slength); | 908 //symbol_add(slength); |
798 | 909 |
799 einit = el_bin(OPER.OPeq, TYM.TYuint, el_var(slength), elength); | 910 einit = el_bin(OPeq, TYM.TYuint, el_var(slength), elength); |
800 } | 911 } |
801 } | 912 } |
802 return einit; | 913 return einit; |
803 } | 914 } |
804 | 915 |