diff options
| author | Pekka Enberg <penberg@kernel.org> | 2011-08-27 15:44:01 +0300 |
|---|---|---|
| committer | Pekka Enberg <penberg@kernel.org> | 2011-08-27 15:49:04 +0300 |
| commit | 8fe6c7a469a65396b03ea58c6fca04b7ca13c99e (patch) | |
| tree | 5fd5d528aa9e1b64704eefc7f4d25e015e483b4b | |
| parent | 397ea4ed08f699ac84d8fa1e4470b15a2632b2e1 (diff) | |
| download | sparse-dev-8fe6c7a469a65396b03ea58c6fca04b7ca13c99e.tar.gz | |
sparse, llvm: Bitwise not operator codegen
Signed-off-by: Pekka Enberg <penberg@kernel.org>
| -rw-r--r-- | sparse-llvm.c | 15 | ||||
| -rw-r--r-- | validation/backend/bitwise-ops.c | 10 |
2 files changed, 24 insertions, 1 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c index 3091b597..3dc51c94 100644 --- a/sparse-llvm.c +++ b/sparse-llvm.c @@ -478,7 +478,20 @@ static void output_insn(struct function *fn, struct instruction *insn) case OP_SLICE: assert(0); break; - case OP_NOT: case OP_NEG: + case OP_NOT: { + LLVMValueRef src, target; + char target_name[64]; + + src = pseudo_to_value(fn, insn->src); + + pseudo_name(insn->target, target_name); + + target = LLVMBuildNot(fn->builder, src, target_name); + + insn->target->priv = target; + break; + } + case OP_NEG: assert(0); break; case OP_CONTEXT: diff --git a/validation/backend/bitwise-ops.c b/validation/backend/bitwise-ops.c index aa1029e4..659c7639 100644 --- a/validation/backend/bitwise-ops.c +++ b/validation/backend/bitwise-ops.c @@ -48,6 +48,16 @@ static unsigned int uxor(unsigned int x, unsigned int y) return x ^ y; } +static int not(int x) +{ + return ~x; +} + +static unsigned int unot(unsigned int x) +{ + return ~x; +} + /* * check-name: Bitwise operator code generation * check-command: ./sparsec -c $file -o tmp.o |
