Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22000

GCC Backend Development - How do I fix `insn does not satisfy its constraints` when compiling a simple program?

$
0
0

I am working on writing a GCC backend for a new architecture. When I try to compile the following simple program with -O0 (note: this error does not occur when optimizations are enabled):

int main(){    int a = 10;    a++;}

I get this error:

test.c: In function ‘main’:test.c:5:1: error: insn does not satisfy its constraints:    5 | }      | ^(insn 8 7 9 (set (reg:SI 12)        (plus:SI (reg:SI 13)            (const_int 1 [0x1]))) "test.c":4:6 1 {addsi3}     (nil))during RTL pass: finaltest.c:5:1: internal compiler error: in final_scan_insn_1, at final.c:30120x65f4b2 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)    ../../gcc/gcc/rtl-error.c:1080x65f4d8 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)    ../../gcc/gcc/rtl-error.c:1180x5e2fc8 final_scan_insn_1    ../../gcc/gcc/final.c:30120xa23e0b final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)    ../../gcc/gcc/final.c:31520xa24099 final_1    ../../gcc/gcc/final.c:20200xa249f2 rest_of_handle_final    ../../gcc/gcc/final.c:46580xa249f2 execute    ../../gcc/gcc/final.c:4736

Based on what the error message say's the problem seems to be with the constraints in addsi3. Here is the definition of addsi3:

(define_insn "addsi3"  [(set (match_operand:SI 0 "register_operand""=r,r")        (plus:SI (match_operand:SI 1 "register_operand""r,r")                 (match_operand:SI 2 "reg_or_imm_operand""r,I")))]"1""@   add %0 %1 %2   addi %0 %1 %2")

The program compiles successfully if the constraints in the definition of addsi3 are removed. Here is the definition for the I constraint:

(define_constraint "I""A 30-bit immediate."  (and (match_code "const_int")       (match_test "ival >= -536870912 && ival <= 536870911")))

Here is the definition of the reg_or_imm_operand predicate.

(define_predicate "reg_or_imm_operand"  (ior (and (match_code "const_int")            (match_test "IN_RANGE (INTVAL (op), -536870912, 536870911)"))       (match_operand 0 "register_operand")))

If more specific information is needed please let me know and I will edit the question.

Thanks in advance. :)


Viewing all articles
Browse latest Browse all 22000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>