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>