diff --git a/FactGenerator/include/predicates.inc b/FactGenerator/include/predicates.inc index 5ab83a5..6aa6ecb 100644 --- a/FactGenerator/include/predicates.inc +++ b/FactGenerator/include/predicates.inc @@ -10,9 +10,11 @@ #define PREDICATE(group, name, fname) #endif // The goal of the above TODO is to move most or all of the below declarations -// from using PREDICATE to PREDICATE2 and PREDICATE_INSTR. +// from using PREDICATE to PREDICATE2S? and PREDICATEIS?. #define PREDICATE2(group, name) PREDICATE(group, name, group ## _ ## name) -#define PREDICATE_INSTR(group, name) PREDICATE(group, name, group ## _instr_ ## name) +#define PREDICATE2S(group, name) PREDICATE(group, name, group ## name) +#define PREDICATEI(group, name) PREDICATE(group, name, group ## _instr_ ## name) +#define PREDICATEIS(group, name) PREDICATE(group, name, group ## instr_ ## name) GROUP_BEGIN(block) PREDICATE2(block, predecessor) @@ -72,125 +74,127 @@ PREDICATE(instr, unreachable, unreachable_instr) GROUP_END(instr) GROUP_BEGIN(add) -PREDICATE(add, instr, add_instr) -PREDICATE(add, first_operand, add_instr_first_operand) -PREDICATE(add, second_operand, add_instr_second_operand) +PREDICATE2(add, instr) +PREDICATEI(add, first_operand) +PREDICATEI(add, second_operand) GROUP_END(add) GROUP_BEGIN(fadd) -PREDICATE(fadd, instr, fadd_instr) -PREDICATE(fadd, first_operand, fadd_instr_first_operand) -PREDICATE(fadd, second_operand, fadd_instr_second_operand) +PREDICATE2(fadd, instr) +PREDICATEI(fadd, first_operand) +PREDICATEI(fadd, second_operand) GROUP_END(fadd) GROUP_BEGIN(sub) -PREDICATE(sub, instr, sub_instr) -PREDICATE(sub, first_operand, sub_instr_first_operand) -PREDICATE(sub, second_operand, sub_instr_second_operand) +PREDICATE2(sub, instr) +PREDICATEI(sub, first_operand) +PREDICATEI(sub, second_operand) GROUP_END(sub) GROUP_BEGIN(fsub) -PREDICATE(fsub, instr, fsub_instr) -PREDICATE(fsub, first_operand, fsub_instr_first_operand) -PREDICATE(fsub, second_operand, fsub_instr_second_operand) +PREDICATE2(fsub, instr) +PREDICATEI(fsub, first_operand) +PREDICATEI(fsub, second_operand) GROUP_END(fsub) GROUP_BEGIN(mul) -PREDICATE(mul, instr, mul_instr) -PREDICATE(mul, first_operand, mul_instr_first_operand) -PREDICATE(mul, second_operand, mul_instr_second_operand) +PREDICATE2(mul, instr) +PREDICATEI(mul, first_operand) +PREDICATEI(mul, second_operand) GROUP_END(mul) GROUP_BEGIN(fmul) -PREDICATE(fmul, instr, fmul_instr) -PREDICATE(fmul, first_operand, fmul_instr_first_operand) -PREDICATE(fmul, second_operand, fmul_instr_second_operand) +PREDICATE2(fmul, instr) +PREDICATEI(fmul, first_operand) +PREDICATEI(fmul, second_operand) GROUP_END(fmul) GROUP_BEGIN(udiv) -PREDICATE(udiv, instr, udiv_instr) -PREDICATE(udiv, first_operand, udiv_instr_first_operand) -PREDICATE(udiv, second_operand, udiv_instr_second_operand) -GROUP_END(udiv) +PREDICATE2(udiv, instr) +PREDICATEI(udiv, first_operand) +PREDICATEI(udiv, second_operand) +GROUP_END(udv) GROUP_BEGIN(fdiv) -PREDICATE(fdiv, instr, fdiv_instr) -PREDICATE(fdiv, first_operand, fdiv_instr_first_operand) -PREDICATE(fdiv, second_operand, fdiv_instr_second_operand) +PREDICATE2(fdiv, instr) +PREDICATEI(fdiv, first_operand) +PREDICATEI(fdiv, second_operand) GROUP_END(fdiv) GROUP_BEGIN(sdiv) -PREDICATE(sdiv, instr, sdiv_instr) -PREDICATE(sdiv, first_operand, sdiv_instr_first_operand) -PREDICATE(sdiv, second_operand, sdiv_instr_second_operand) +PREDICATE2(sdiv, instr) +PREDICATEI(sdiv, first_operand) +PREDICATEI(sdiv, second_operand) GROUP_END(sdiv) GROUP_BEGIN(urem) -PREDICATE(urem, instr, urem_instr) -PREDICATE(urem, first_operand, urem_instr_first_operand) -PREDICATE(urem, second_operand, urem_instr_second_operand) +PREDICATE2(urem, instr) +PREDICATEI(urem, first_operand) +PREDICATEI(urem, second_operand) GROUP_END(urem) GROUP_BEGIN(srem) -PREDICATE(srem, instr, srem_instr) -PREDICATE(srem, first_operand, srem_instr_first_operand) -PREDICATE(srem, second_operand, srem_instr_second_operand) +PREDICATE2(srem, instr) +PREDICATEI(srem, first_operand) +PREDICATEI(srem, second_operand) GROUP_END(srem) GROUP_BEGIN(frem) -PREDICATE(frem, instr, frem_instr) -PREDICATE(frem, first_operand, frem_instr_first_operand) -PREDICATE(frem, second_operand, frem_instr_second_operand) +PREDICATE2(frem, instr) +PREDICATEI(frem, first_operand) +PREDICATEI(frem, second_operand) GROUP_END(frem) // Bitwise Binary Instrs GROUP_BEGIN(shl) -PREDICATE(shl, instr, shl_instr) -PREDICATE(shl, first_operand, shl_instr_first_operand) -PREDICATE(shl, second_operand, shl_instr_second_operand) +PREDICATE2(shl, instr) +PREDICATEI(shl, first_operand) +PREDICATEI(shl, second_operand) GROUP_END(shl) GROUP_BEGIN(lshr) -PREDICATE(lshr, instr, lshr_instr) -PREDICATE(lshr, first_operand, lshr_instr_first_operand) -PREDICATE(lshr, second_operand, lshr_instr_second_operand) +PREDICATE2(lshr, instr) +PREDICATEI(lshr, first_operand) +PREDICATEI(lshr, second_operand) GROUP_END(lshr) GROUP_BEGIN(ashr) -PREDICATE(ashr, instr, ashr_instr) -PREDICATE(ashr, first_operand, ashr_instr_first_operand) -PREDICATE(ashr, second_operand, ashr_instr_second_operand) +PREDICATE2(ashr, instr) +PREDICATEI(ashr, first_operand) +PREDICATEI(ashr, second_operand) GROUP_END(ashr) GROUP_BEGIN(and_) -PREDICATE(and_, instr, and_instr) -PREDICATE(and_, first_operand, and_instr_first_operand) -PREDICATE(and_, second_operand, and_instr_second_operand) +PREDICATE2S(and_, instr) +PREDICATEIS(and_, first_operand) +PREDICATEIS(and_, second_operand) GROUP_END(and_) GROUP_BEGIN(or_) -PREDICATE(or_, instr, or_instr) -PREDICATE(or_, first_operand, or_instr_first_operand) -PREDICATE(or_, second_operand, or_instr_second_operand) +PREDICATE2S(or_, instr) +PREDICATEIS(or_, first_operand) +PREDICATEIS(or_, second_operand) GROUP_END(or_) GROUP_BEGIN(xor_) -PREDICATE(xor_, instr, xor_instr) -PREDICATE(xor_, first_operand, xor_instr_first_operand) -PREDICATE(xor_, second_operand, xor_instr_second_operand) +PREDICATE2S(xor_, instr) +PREDICATEIS(xor_, first_operand) +PREDICATEIS(xor_, second_operand) GROUP_END(xor_) // Terminator Instrs GROUP_BEGIN(ret) -PREDICATE(ret, instr, ret_instr) +PREDICATE2(ret, instr) +// TODO(lb): PREDICATE(ret, instr_void, void_ret_instr) +// TODO(lb): PREDICATE(ret, operand, ret_instr_value) GROUP_END(ret) GROUP_BEGIN(br) -PREDICATE(br, instr, br_instr) +PREDICATE2(br, instr) PREDICATE(br, instr_cond, br_cond_instr) PREDICATE(br, condition, br_cond_instr_condition) PREDICATE(br, cond_iftrue, br_cond_instr_iftrue_label) @@ -200,28 +204,30 @@ PREDICATE(br, uncond_dest, br_uncond_instr_dest_label) GROUP_END(br) GROUP_BEGIN(switch_) -PREDICATE(switch_, instr, switch_instr) -PREDICATE(switch_, operand, switch_instr_operand) -PREDICATE(switch_, default_label, switch_instr_default_label) +PREDICATE2S(switch_, instr) +PREDICATEIS(switch_, operand) +PREDICATEIS(switch_, default_label) +// TODO(lb): Remove leading underscores PREDICATE(switch_, case_value, _switch_instr_case_value) PREDICATE(switch_, case_label, _switch_instr_case_label) -PREDICATE(switch_, ncases, switch_instr_ncases) +PREDICATEIS(switch_, ncases) GROUP_END(switch_) GROUP_BEGIN(indirectbr) -PREDICATE(indirectbr, instr, indirectbr_instr) -PREDICATE(indirectbr, address, indirectbr_instr_address) -PREDICATE(indirectbr, label, indirectbr_instr_label) -PREDICATE(indirectbr, nlabels, indirectbr_instr_nlabels) +PREDICATE2(indirectbr, instr) +PREDICATEI(indirectbr, address) +PREDICATEI(indirectbr, label) +PREDICATEI(indirectbr, nlabels) GROUP_END(indirectbr) GROUP_BEGIN(resume) -PREDICATE(resume, instr, resume_instr) -PREDICATE(resume, operand, resume_instr_operand) +PREDICATE2(resume, instr) +PREDICATEI(resume, operand) GROUP_END(resume) GROUP_BEGIN(invoke) -PREDICATE(invoke, instr, invoke_instr) +PREDICATE2(invoke, instr) +// TODO(lb): Rename for consistency PREDICATE(invoke, instr_direct, direct_invoke_instr) PREDICATE(invoke, instr_indirect, indirect_invoke_instr) PREDICATE(invoke, function, invoke_instr_fn_operand) @@ -237,12 +243,14 @@ GROUP_END(invoke) // Vector Operations GROUP_BEGIN(extract_element) +// TODO(lb): Rename extract_element to extractelement PREDICATE(extract_element, instr, extractelement_instr) PREDICATE(extract_element, base, extractelement_instr_base) PREDICATE(extract_element, index, extractelement_instr_index) GROUP_END(extract_element) GROUP_BEGIN(insert_element) +// TODO(lb): Rename insert_element to insertelement PREDICATE(insert_element, instr, insertelement_instr) PREDICATE(insert_element, base, insertelement_instr_base) PREDICATE(insert_element, index, insertelement_instr_index) @@ -250,6 +258,7 @@ PREDICATE(insert_element, value, insertelement_instr_value) GROUP_END(insert_element) GROUP_BEGIN(shuffle_vector) +// TODO(lb): Rename shuffle_vector to shufflevector PREDICATE(shuffle_vector, instr, shufflevector_instr) PREDICATE(shuffle_vector, first_vector, shufflevector_instr_first_vector) PREDICATE(shuffle_vector, second_vector, shufflevector_instr_second_vector) @@ -259,6 +268,7 @@ GROUP_END(shuffle_vector) // Aggregate Operations GROUP_BEGIN(extract_value) +// TODO(lb): Rename extract_value to extractvalue PREDICATE(extract_value, instr, extractvalue_instr) PREDICATE(extract_value, base, extractvalue_instr_base) PREDICATE(extract_value, index, extractvalue_instr_index) @@ -266,6 +276,7 @@ PREDICATE(extract_value, nindices, extractvalue_instr_nindices) GROUP_END(extract_value) GROUP_BEGIN(insert_value) +// TODO(lb): Rename insert_value to insertvalue PREDICATE(insert_value, instr, insertvalue_instr) PREDICATE(insert_value, base, insertvalue_instr_base) PREDICATE(insert_value, value, insertvalue_instr_value) @@ -276,54 +287,59 @@ GROUP_END(insert_value) // Memory Operations GROUP_BEGIN(alloca) -PREDICATE(alloca, instr, alloca_instr) -PREDICATE(alloca, size, alloca_instr_size) -PREDICATE(alloca, alignment, alloca_instr_alignment) -PREDICATE(alloca, type, alloca_instr_type) +PREDICATE2(alloca, instr) +PREDICATEI(alloca, size) +PREDICATEI(alloca, alignment) +PREDICATEI(alloca, type) GROUP_END(alloca) GROUP_BEGIN(load) -PREDICATE(load, instr, load_instr) -PREDICATE(load, alignment, load_instr_alignment) -PREDICATE(load, ordering, load_instr_ordering) -PREDICATE(load, address, load_instr_address) +PREDICATE2(load, instr) +PREDICATEI(load, alignment) +PREDICATEI(load, ordering) +PREDICATEI(load, address) +// TODO(lb): PREDICATE(load, isvolatile, load_instr_is_volatile) GROUP_END(load) GROUP_BEGIN(store) -PREDICATE(store, instr, store_instr) -PREDICATE(store, alignment, store_instr_alignment) -PREDICATE(store, ordering, store_instr_ordering) -PREDICATE(store, value, store_instr_value) -PREDICATE(store, address, store_instr_address) +PREDICATE2(store, instr) +PREDICATEI(store, alignment) +PREDICATEI(store, ordering) +PREDICATEI(store, value) +PREDICATEI(store, address) +// TODO(lb): PREDICATE(store, isvolatile, store_instr_is_volatile) GROUP_END(store) GROUP_BEGIN(fence) -PREDICATE(fence, instr, fence_instr) -PREDICATE(fence, ordering, fence_instr_ordering) +PREDICATE2(fence, instr) +PREDICATEI(fence, ordering) GROUP_END(fence) GROUP_BEGIN(atomicrmw) -PREDICATE(atomicrmw, instr, atomicrmw_instr) -PREDICATE(atomicrmw, ordering, atomicrmw_instr_ordering) -PREDICATE(atomicrmw, operation, atomicrmw_instr_operation) -PREDICATE(atomicrmw, address, atomicrmw_instr_address) -PREDICATE(atomicrmw, value, atomicrmw_instr_value) +PREDICATE2(atomicrmw, instr) +PREDICATEI(atomicrmw, ordering) +PREDICATEI(atomicrmw, operation) +PREDICATEI(atomicrmw, address) +PREDICATEI(atomicrmw, value) +// TODO(lb): PREDICATE(atomicrmw, isvolatile, atomicrmw_instr_is_volatile) GROUP_END(atomicrmw) GROUP_BEGIN(cmpxchg) -PREDICATE(cmpxchg, instr, cmpxchg_instr) -PREDICATE(cmpxchg, ordering, cmpxchg_instr_ordering) -PREDICATE(cmpxchg, address, cmpxchg_instr_address) -PREDICATE(cmpxchg, cmp_value, cmpxchg_instr_cmp_value) -PREDICATE(cmpxchg, new_value, cmpxchg_instr_new_value) -PREDICATE(cmpxchg, type, cmpxchg_instr_type) +PREDICATE2(cmpxchg, instr) +PREDICATEI(cmpxchg, ordering) +PREDICATEI(cmpxchg, address) +PREDICATEI(cmpxchg, cmp_value) +PREDICATEI(cmpxchg, new_value) +PREDICATEI(cmpxchg, type) +// TODO(lb): PREDICATE(cmpxchg, isvolatile, cmpxchg_instr_is_volatile) GROUP_END(cmpxchg) GROUP_BEGIN(gep) +// TODO(lb): Rename getelementptr to gep in Datalog PREDICATE(gep, instr, getelementptr_instr) PREDICATE(gep, base, getelementptr_instr_base) PREDICATE(gep, index, getelementptr_instr_index) @@ -334,9 +350,9 @@ GROUP_END(gep) // Conversion Operations GROUP_BEGIN(trunc) -PREDICATE(trunc, instr, trunc_instr) -PREDICATE(trunc, from_operand, trunc_instr_from_operand) -PREDICATE(trunc, to_type, trunc_instr_to_type) +PREDICATE2(trunc, instr) +PREDICATEI(trunc, from_operand) +PREDICATEI(trunc, to_type) GROUP_END(trunc) GROUP_BEGIN(zext) diff --git a/doc/dev.rst b/doc/dev.rst index bbd4991..13d3a55 100644 --- a/doc/dev.rst +++ b/doc/dev.rst @@ -53,7 +53,7 @@ space. This judgment is highly subjective, but must be made somehow. - ``global_var``: Global variable - ``expr``: Expression - ``func``: Function -- ``gep``: ``getelementptr`` +- ``gep``: ``getelementptr`` (this is the only abbreviated opcode) - ``instr``: Instruction - ``int``: Integer - ``param``: Parameter