Mercurial > hg > graal-compiler
comparison src/share/vm/adlc/archDesc.cpp @ 6850:d336b3173277
8000592: Improve adlc usability
Summary: several changes to adlc to improve its usability
Reviewed-by: kvn
Contributed-by: goetz.lindenmaier@sap.com
author | kvn |
---|---|
date | Tue, 09 Oct 2012 16:09:31 -0700 |
parents | 8e47bac5643a |
children | 70c52efb2cbd |
comparison
equal
deleted
inserted
replaced
6849:f6badecb7ea7 | 6850:d336b3173277 |
---|---|
219 | 219 |
220 // Initialize Register & Pipeline Form Pointers | 220 // Initialize Register & Pipeline Form Pointers |
221 _register = NULL; | 221 _register = NULL; |
222 _encode = NULL; | 222 _encode = NULL; |
223 _pipeline = NULL; | 223 _pipeline = NULL; |
224 _frame = NULL; | |
224 } | 225 } |
225 | 226 |
226 ArchDesc::~ArchDesc() { | 227 ArchDesc::~ArchDesc() { |
227 // Clean-up and quit | 228 // Clean-up and quit |
228 | 229 |
646 | 647 |
647 //------------------------------get_preproc_def-------------------------------- | 648 //------------------------------get_preproc_def-------------------------------- |
648 // Return the textual binding for a given CPP flag name. | 649 // Return the textual binding for a given CPP flag name. |
649 // Return NULL if there is no binding, or it has been #undef-ed. | 650 // Return NULL if there is no binding, or it has been #undef-ed. |
650 char* ArchDesc::get_preproc_def(const char* flag) { | 651 char* ArchDesc::get_preproc_def(const char* flag) { |
651 SourceForm* deff = (SourceForm*) _preproc_table[flag]; | 652 // In case of syntax errors, flag may take the value NULL. |
653 SourceForm* deff = NULL; | |
654 if (flag != NULL) | |
655 deff = (SourceForm*) _preproc_table[flag]; | |
652 return (deff == NULL) ? NULL : deff->_code; | 656 return (deff == NULL) ? NULL : deff->_code; |
653 } | 657 } |
654 | 658 |
655 | 659 |
656 //------------------------------set_preproc_def-------------------------------- | 660 //------------------------------set_preproc_def-------------------------------- |
801 if (!quiet) { /* no output if in quiet mode */ | 805 if (!quiet) { /* no output if in quiet mode */ |
802 i = fprintf(errfile, "%s(%d) ", _ADL_file._name, line); | 806 i = fprintf(errfile, "%s(%d) ", _ADL_file._name, line); |
803 while (i++ <= 15) fputc(' ', errfile); | 807 while (i++ <= 15) fputc(' ', errfile); |
804 fprintf(errfile, "%-8s:", pref); | 808 fprintf(errfile, "%-8s:", pref); |
805 vfprintf(errfile, fmt, args); | 809 vfprintf(errfile, fmt, args); |
806 fprintf(errfile, "\n"); } | 810 fprintf(errfile, "\n"); |
811 fflush(errfile); | |
812 } | |
807 return 1; | 813 return 1; |
808 } | 814 } |
809 | 815 |
810 | 816 |
811 // --------------------------------------------------------------------------- | 817 // --------------------------------------------------------------------------- |
853 const char *ArchDesc::reg_mask(OperandForm &opForm) { | 859 const char *ArchDesc::reg_mask(OperandForm &opForm) { |
854 const char *regMask = "RegMask::Empty"; | 860 const char *regMask = "RegMask::Empty"; |
855 | 861 |
856 // Check constraints on result's register class | 862 // Check constraints on result's register class |
857 const char *result_class = opForm.constrained_reg_class(); | 863 const char *result_class = opForm.constrained_reg_class(); |
858 if (!result_class) opForm.dump(); | 864 if (result_class == NULL) { |
859 assert( result_class, "Resulting register class was not defined for operand"); | 865 opForm.dump(); |
866 syntax_err(opForm._linenum, | |
867 "Use of an undefined result class for operand: %s", | |
868 opForm._ident); | |
869 abort(); | |
870 } | |
871 | |
860 regMask = reg_class_to_reg_mask( result_class ); | 872 regMask = reg_class_to_reg_mask( result_class ); |
861 | 873 |
862 return regMask; | 874 return regMask; |
863 } | 875 } |
864 | 876 |
865 // Obtain the name of the RegMask for an InstructForm | 877 // Obtain the name of the RegMask for an InstructForm |
866 const char *ArchDesc::reg_mask(InstructForm &inForm) { | 878 const char *ArchDesc::reg_mask(InstructForm &inForm) { |
867 const char *result = inForm.reduce_result(); | 879 const char *result = inForm.reduce_result(); |
868 assert( result, | 880 |
869 "Did not find result operand or RegMask for this instruction"); | 881 if (result == NULL) { |
882 syntax_err(inForm._linenum, | |
883 "Did not find result operand or RegMask" | |
884 " for this instruction: %s", | |
885 inForm._ident); | |
886 abort(); | |
887 } | |
870 | 888 |
871 // Instructions producing 'Universe' use RegMask::Empty | 889 // Instructions producing 'Universe' use RegMask::Empty |
872 if( strcmp(result,"Universe")==0 ) { | 890 if( strcmp(result,"Universe")==0 ) { |
873 return "RegMask::Empty"; | 891 return "RegMask::Empty"; |
874 } | 892 } |
875 | 893 |
876 // Lookup this result operand and get its register class | 894 // Lookup this result operand and get its register class |
877 Form *form = (Form*)_globalNames[result]; | 895 Form *form = (Form*)_globalNames[result]; |
878 assert( form, "Result operand must be defined"); | 896 if (form == NULL) { |
897 syntax_err(inForm._linenum, | |
898 "Did not find result operand for result: %s", result); | |
899 abort(); | |
900 } | |
879 OperandForm *oper = form->is_operand(); | 901 OperandForm *oper = form->is_operand(); |
880 if (oper == NULL) form->dump(); | 902 if (oper == NULL) { |
881 assert( oper, "Result must be an OperandForm"); | 903 syntax_err(inForm._linenum, "Form is not an OperandForm:"); |
904 form->dump(); | |
905 abort(); | |
906 } | |
882 return reg_mask( *oper ); | 907 return reg_mask( *oper ); |
883 } | 908 } |
884 | 909 |
885 | 910 |
886 // Obtain the STACK_OR_reg_mask name for an OperandForm | 911 // Obtain the STACK_OR_reg_mask name for an OperandForm |
887 char *ArchDesc::stack_or_reg_mask(OperandForm &opForm) { | 912 char *ArchDesc::stack_or_reg_mask(OperandForm &opForm) { |
888 // name of cisc_spillable version | 913 // name of cisc_spillable version |
889 const char *reg_mask_name = reg_mask(opForm); | 914 const char *reg_mask_name = reg_mask(opForm); |
890 assert( reg_mask_name != NULL, "called with incorrect opForm"); | 915 |
916 if (reg_mask_name == NULL) { | |
917 syntax_err(opForm._linenum, | |
918 "Did not find reg_mask for opForm: %s", | |
919 opForm._ident); | |
920 abort(); | |
921 } | |
891 | 922 |
892 const char *stack_or = "STACK_OR_"; | 923 const char *stack_or = "STACK_OR_"; |
893 int length = (int)strlen(stack_or) + (int)strlen(reg_mask_name) + 1; | 924 int length = (int)strlen(stack_or) + (int)strlen(reg_mask_name) + 1; |
894 char *result = new char[length]; | 925 char *result = new char[length]; |
895 sprintf(result,"%s%s", stack_or, reg_mask_name); | 926 sprintf(result,"%s%s", stack_or, reg_mask_name); |