On Feb 14, 2020, at 1:26 PM, Segher Boessenkool <seg...@kernel.crashing.org> 
wrote:
> It remains to be seen how much of it can be used by other targets.
> Pretending something is generic while it in fact is just a mass of
> special cases isn't useful, it's just costly.

Oh, yeah, of course.  Ours was designed in two pieces, the target bits, which 
were 100% target specific, and then the infrastructure to make those target 
bits go.  5,661 lines in the generator, and around 11 lines per builtin on the 
target side.  The generator was 100% free of target things.


(define_code_attr cond_name
        [(unordered "Unordered")
         (ordered "Ordered")
         (unlt "Less Than or Unordered")
         (unge "Greater Than or Equal or Unordered")
         (uneq "Equal or Unordered")
         (ltgt "Not Equal or Unordered")
         (unle "Less Than or Equal or Unorderd")
         (ungt "Greater Than or Unordered")
         (eq "Equal")
         (ne "Not Equal")
         (gt "Greater Than")
         (ge "Greater Equal")
         (lt "Less Than")
         (le "Less Equal")
         (gtu "Greater Than Unsigned")
         (geu "Greater Than Unsigned")
         (ltu "Less Than Unsigned")
         (leu "Less Than Unsigned")])



(define_builtin "arch_cmp<icond>" "arch_cmp<icond>_<type>"
  [
    (define_desc    "Compare <cond_name>")
    (define_outputs [(var_operand:<T_ALL_INT:TU_TYPE> 0)])
    (define_inputs  [(var_operand:T_ALL_INT 1)
                     (var_operand:T_ALL_INT 2)])
    (code_iterator icond)
    (define_rtl_pattern "arch_cmp<icond>_<mode>" [0 1 2])
    (attributes [pure])
    (use_note "<GCCOP>")
  ]
)

was the typical sort of thing for the target side.  We've since moved on and 
now generate even more from way less.  3 lines of input for an instruction, and 
even the 3 lines are auto extracted from the documentation for the instruction. 
 So, roughly zero lines of input per builtin.  About 5600 lines in the 
generator code, but that generator, oh my, it does a ton more.  The new one 
doesn't have the nice clean split between target and non-target code, however.  
The later does significantly more work however, so, I don't feel bad.

The one thing missing I think more from modern compiler port development is the 
sharing of the commonalities between ports that would make the port writing 
even easier.

Reply via email to