66 ARRAYBOUNDSCHECKInstID,
94 BaseIndexDisplacement,
95 BaseIndexDisplacement2,
98 BaseIndexMultiplierDisplacement,
99 BaseIndexMultiplierDisplacement2,
111 #define burm_stm_NT 1
115 for (
int i=1;
i <= 1; ++
i) cost[
i] = 0x7fff;
120 unsigned int burm_stm:6;
132 static short burm_nts_0[] = { 0 };
133 static short burm_nts_1[] = { burm_stm_NT, 0 };
134 static short burm_nts_2[] = { burm_stm_NT, burm_stm_NT, 0 };
135 static short burm_nts_3[] = { burm_stm_NT, burm_stm_NT, burm_stm_NT, 0 };
137 static short *burm_nts[] = {
183 static const char *burm_templates[] = {
189 "ARRAYBOUNDSCHECKInstID",
210 "LOOKUPSWITCHInstID",
217 "BaseIndexDisplacement",
218 "BaseIndexDisplacement2",
219 "BaseIndexMultiplier",
220 "BaseIndexMultiplier2",
221 "BaseIndexMultiplierDisplacement",
222 "BaseIndexMultiplierDisplacement2",
229 static char burm_isinstruction[] = {
275 static const char *burm_string[] = {
279 "stm: CHECKNULLInstID",
280 "stm: ARRAYLENGTHInstID(stm)",
281 "stm: ARRAYBOUNDSCHECKInstID(stm,stm)",
282 "stm: NEGInstID(stm)",
283 "stm: CASTInstID(stm)",
284 "stm: ADDInstID(stm,stm)",
285 "stm: SUBInstID(stm,stm)",
286 "stm: MULInstID(stm,stm)",
287 "stm: DIVInstID(stm,stm)",
288 "stm: REMInstID(stm,stm)",
291 "stm: ANDInstID(stm,stm)",
292 "stm: ORInstID(stm,stm)",
293 "stm: XORInstID(stm,stm)",
294 "stm: CMPInstID(stm,stm)",
296 "stm: AREFInstID(stm,stm)",
297 "stm: ASTOREInstID(stm,stm)",
298 "stm: ALOADInstID(stm)",
300 "stm: IFInstID(stm,stm)",
301 "stm: TABLESWITCHInstID(stm)",
302 "stm: LOOKUPSWITCHInstID(stm)",
303 "stm: RETURNInstID(stm)",
305 "stm: ADDInstID(CONSTInstID,CONSTInstID)",
306 "stm: ADDInstID(stm,CONSTInstID)",
307 "stm: SUBInstID(stm,CONSTInstID)",
308 "stm: MULInstID(stm,CONSTInstID)",
309 "stm: ADDInstID(ADDInstID(stm,stm),CONSTInstID)",
310 "stm: ADDInstID(stm,ADDInstID(stm,CONSTInstID))",
311 "stm: ADDInstID(stm,MULInstID(stm,CONSTInstID))",
312 "stm: ADDInstID(MULInstID(stm,CONSTInstID),stm)",
313 "stm: ADDInstID(ADDInstID(stm,MULInstID(stm,CONSTInstID)),CONSTInstID)",
314 "stm: ADDInstID(stm,ADDInstID(MULInstID(stm,CONSTInstID),CONSTInstID))",
315 "stm: AREFInstID(stm,stm)",
316 "stm: ALOADInstID(AREFInstID(stm,stm))",
317 "stm: ASTOREInstID(AREFInstID(stm,stm),stm)",
318 "stm: ASTOREInstID(AREFInstID(stm,stm),CONSTInstID)",
321 static short burm_decode_stm[] = {
373 int burm_rule(shared_ptr<STATE_TYPE> state,
int goalnt);
397 bool isMultiplier(CONSTInst* c){
398 s8 val = c->get_value();
399 if ((val == 2) || (val == 4) || (val == 8))
return true;
403 bool isConstEncodable(CONSTInst* c){
404 return fits_into<s4>(c->get_value());
407 bool isDiscreteValue(Instruction* a){
408 return (a->get_type() == Type::ByteTypeID ||
409 a->get_type() == Type::IntTypeID ||
410 a->get_type() == Type::LongTypeID);
413 int encodeDiscreteCost(Instruction* a,
Value* c){
414 if (!isDiscreteValue(a))
416 if (!isConstEncodable(c->to_Instruction()->to_CONSTInst()))
429 int calcBaseIndexDisplacementCost(Instruction* a){
437 if (isConstEncodable(a->get_operand(1)->to_Instruction()->to_CONSTInst()))
442 int calcBaseIndexDisplacement2Cost(Instruction* a){
450 if (isConstEncodable(a->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst()))
455 int calcBaseIndexMultiplierCost(Instruction* a){
463 if (isMultiplier(a->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst()))
468 int calcBaseIndexMultiplier2Cost(Instruction* a){
476 if (isMultiplier(a->get_operand(0)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst()))
481 int calcBaseIndexMultiplierDisplacementCost(Instruction* a){
492 if ((isConstEncodable(a->get_operand(1)->to_Instruction()->to_CONSTInst())) &&
493 (isMultiplier(a->get_operand(0)->to_Instruction()->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst())))
498 int calcBaseIndexMultiplierDisplacement2Cost(Instruction* a){
508 if ((isConstEncodable(a->get_operand(1)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst())) &&
509 (isMultiplier(a->get_operand(1)->to_Instruction()->get_operand(0)->to_Instruction()->get_operand(1)->to_Instruction()->to_CONSTInst())))
516 int Matcher::burm_rule(shared_ptr<STATE_TYPE> state,
int goalnt) {
517 if (goalnt < 1 || goalnt > 1)
518 ABORT_MSG(
"burm_rule",
"Bad goal nonterminal " << goalnt <<
nl);
522 case burm_stm_NT:
return burm_decode_stm[state->rule.burm_stm];
524 ABORT_MSG(
"burm_rule",
"Bad goal nonterminal " << goalnt <<
nl);
532 shared_ptr<STATE_TYPE> p;
540 if (1 + 0 < p->cost[burm_stm_NT]) {
541 p->cost[burm_stm_NT] = 1 + 0;
542 p->rule.burm_stm = 1;
547 if (1 + 0 < p->cost[burm_stm_NT]) {
548 p->cost[burm_stm_NT] = 1 + 0;
549 p->rule.burm_stm = 2;
554 if (1 + 0 < p->cost[burm_stm_NT]) {
555 p->cost[burm_stm_NT] = 1 + 0;
556 p->rule.burm_stm = 3;
564 if (c + 0 < p->cost[burm_stm_NT]) {
565 p->cost[burm_stm_NT] = c + 0;
566 p->rule.burm_stm = 4;
575 if (c + 0 < p->cost[burm_stm_NT]) {
576 p->cost[burm_stm_NT] = c + 0;
577 p->rule.burm_stm = 5;
585 if (c + 0 < p->cost[burm_stm_NT]) {
586 p->cost[burm_stm_NT] = c + 0;
587 p->rule.burm_stm = 6;
595 if (c + 0 < p->cost[burm_stm_NT]) {
596 p->cost[burm_stm_NT] = c + 0;
597 p->rule.burm_stm = 7;
606 if (c + 0 < p->cost[burm_stm_NT]) {
607 p->cost[burm_stm_NT] = c + 0;
608 p->rule.burm_stm = 8;
615 if (c + 0 < p->cost[burm_stm_NT]) {
616 p->cost[burm_stm_NT] = c + 0;
617 p->rule.burm_stm = 29;
624 if (c + 0 < p->cost[burm_stm_NT]) {
625 p->cost[burm_stm_NT] = c + 0;
626 p->rule.burm_stm = 30;
634 if (c + 0 < p->cost[burm_stm_NT]) {
635 p->cost[burm_stm_NT] = c + 0;
636 p->rule.burm_stm = 33;
644 if (c + 0 < p->cost[burm_stm_NT]) {
645 p->cost[burm_stm_NT] = c + 0;
646 p->rule.burm_stm = 34;
654 if (c + 0 < p->cost[burm_stm_NT]) {
655 p->cost[burm_stm_NT] = c + 0;
656 p->rule.burm_stm = 35;
664 if (c + 0 < p->cost[burm_stm_NT]) {
665 p->cost[burm_stm_NT] = c + 0;
666 p->rule.burm_stm = 36;
676 if (c + 0 < p->cost[burm_stm_NT]) {
677 p->cost[burm_stm_NT] = c + 0;
678 p->rule.burm_stm = 37;
688 if (c + 0 < p->cost[burm_stm_NT]) {
689 p->cost[burm_stm_NT] = c + 0;
690 p->rule.burm_stm = 38;
700 if (c + 0 < p->cost[burm_stm_NT]) {
701 p->cost[burm_stm_NT] = c + 0;
702 p->rule.burm_stm = 9;
708 if (c + 0 < p->cost[burm_stm_NT]) {
709 p->cost[burm_stm_NT] = c + 0;
710 p->rule.burm_stm = 31;
720 if (c + 0 < p->cost[burm_stm_NT]) {
721 p->cost[burm_stm_NT] = c + 0;
722 p->rule.burm_stm = 10;
728 if (c + 0 < p->cost[burm_stm_NT]) {
729 p->cost[burm_stm_NT] = c + 0;
730 p->rule.burm_stm = 32;
740 if (c + 0 < p->cost[burm_stm_NT]) {
741 p->cost[burm_stm_NT] = c + 0;
742 p->rule.burm_stm = 11;
751 if (c + 0 < p->cost[burm_stm_NT]) {
752 p->cost[burm_stm_NT] = c + 0;
753 p->rule.burm_stm = 12;
758 if (1 + 0 < p->cost[burm_stm_NT]) {
759 p->cost[burm_stm_NT] = 1 + 0;
760 p->rule.burm_stm = 13;
765 if (1 + 0 < p->cost[burm_stm_NT]) {
766 p->cost[burm_stm_NT] = 1 + 0;
767 p->rule.burm_stm = 14;
776 if (c + 0 < p->cost[burm_stm_NT]) {
777 p->cost[burm_stm_NT] = c + 0;
778 p->rule.burm_stm = 15;
787 if (c + 0 < p->cost[burm_stm_NT]) {
788 p->cost[burm_stm_NT] = c + 0;
789 p->rule.burm_stm = 16;
798 if (c + 0 < p->cost[burm_stm_NT]) {
799 p->cost[burm_stm_NT] = c + 0;
800 p->rule.burm_stm = 17;
809 if (c + 0 < p->cost[burm_stm_NT]) {
810 p->cost[burm_stm_NT] = c + 0;
811 p->rule.burm_stm = 18;
816 if (1 + 0 < p->cost[burm_stm_NT]) {
817 p->cost[burm_stm_NT] = 1 + 0;
818 p->rule.burm_stm = 19;
827 if (c + 0 < p->cost[burm_stm_NT]) {
828 p->cost[burm_stm_NT] = c + 0;
829 p->rule.burm_stm = 20;
833 if (c + 0 < p->cost[burm_stm_NT]) {
834 p->cost[burm_stm_NT] = c + 0;
835 p->rule.burm_stm = 39;
844 if (c + 0 < p->cost[burm_stm_NT]) {
845 p->cost[burm_stm_NT] = c + 0;
846 p->rule.burm_stm = 21;
852 if (c + 0 < p->cost[burm_stm_NT]) {
853 p->cost[burm_stm_NT] = c + 0;
854 p->rule.burm_stm = 41;
862 if (c + 0 < p->cost[burm_stm_NT]) {
863 p->cost[burm_stm_NT] = c + 0;
864 p->rule.burm_stm = 42;
873 if (c + 0 < p->cost[burm_stm_NT]) {
874 p->cost[burm_stm_NT] = c + 0;
875 p->rule.burm_stm = 22;
881 if (c + 0 < p->cost[burm_stm_NT]) {
882 p->cost[burm_stm_NT] = c + 0;
883 p->rule.burm_stm = 40;
889 if (1 + 0 < p->cost[burm_stm_NT]) {
890 p->cost[burm_stm_NT] = 1 + 0;
891 p->rule.burm_stm = 23;
900 if (c + 0 < p->cost[burm_stm_NT]) {
901 p->cost[burm_stm_NT] = c + 0;
902 p->rule.burm_stm = 24;
910 if (c + 0 < p->cost[burm_stm_NT]) {
911 p->cost[burm_stm_NT] = c + 0;
912 p->rule.burm_stm = 25;
920 if (c + 0 < p->cost[burm_stm_NT]) {
921 p->cost[burm_stm_NT] = c + 0;
922 p->rule.burm_stm = 26;
930 if (c + 0 < p->cost[burm_stm_NT]) {
931 p->cost[burm_stm_NT] = c + 0;
932 p->rule.burm_stm = 27;
937 if (1 + 0 < p->cost[burm_stm_NT]) {
938 p->cost[burm_stm_NT] = 1 + 0;
939 p->rule.burm_stm = 28;
1021 ABORT_MSG(
"burm_kids",
"Bad rule number " << eruleno <<
nl);
Instruction * NODEPTR_TYPE
Represents the result of the addition of a certain IR-variable with a certain constant.
#define ABORT_MSG(EXPR_SHORT, EXPR_LONG)
struct burm_state STATE_TYPE