sparse, llvm: Simplify comparison op code generation
commit58f7c712b643db22fe46ecfb9fa39a93a57ddfa9
authorPekka Enberg <penberg@kernel.org>
Tue, 22 Nov 2011 17:54:16 +0000 (22 19:54 +0200)
committerPekka Enberg <penberg@kernel.org>
Tue, 22 Nov 2011 20:06:29 +0000 (22 22:06 +0200)
treec8c6503e260b801aaebb0822705425749c0c4381
parentb08efe9f3e4513b3418dce040340e9fffa42bc15
sparse, llvm: Simplify comparison op code generation

Linus writes:

  On Tue, Nov 22, 2011 at 9:40 AM, Pekka Enberg <penberg@kernel.org> wrote:
  > This patch implements LLVM code generation for OP_SET_LE, OP_SET_GE, OP_SET_BE,
  > and OP_SET_AE.

  Ugh.

  Can't you just do it with a single statement like

     target = LLVMBuildICmp(fn->builder, translate_op(op), lhs, rhs,
target_name);

  instead of having that case-statement where every case does the same thing?

  The translate_op() thing should be trivial too, just something like

    static int translate_op(int sparse_op)
    {
        static const int trans_tbl[] = {
            .[OP_SET_LE] = LLVMIntSLE,
        ...
         };
         return trans_tbl[sparse_op];
    }

  or whatever. No?

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse-llvm.c