InstCombine Dialect #
This file defines a dialect of basic arithmetic and bitwise operations on bitvectors.
The dialect supports types of arbitrary-width bitvectors.
Thus, some definitions wil be parameterized by φ
, the number of width meta-variables there are.
This parameter will usually be either 0
, indicating that all widths are known, concrete values,
or 1
, indicating there is exactly one distinct width meta-variable.
In particular, we only define a denotational semantics for concrete programs (i.e., where φ = 0
)
see https://releases.llvm.org/14.0.0/docs/LangRef.html#bitwise-binary-operations
Equations
Instances For
- bitvec: {φ : ℕ} → InstCombine.Width φ → InstCombine.MTy φ
Instances For
Equations
- InstCombine.instDecidableEqMTy = InstCombine.decEqMTy✝
Equations
- InstCombine.instInhabitedMTy = { default := InstCombine.MTy.bitvec default }
Equations
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- InstCombine.instToFormatMTy = { format := repr }
Equations
- InstCombine.instToStringMTy = { toString := fun (t : InstCombine.MTy φ) => (repr t).pretty }
Equations
Instances For
Equations
Instances For
Equations
- InstCombine.instTyDenoteTy = { toType := fun (x : InstCombine.Ty) => match x with | InstCombine.MTy.bitvec (ConcreteOrMVar.concrete w) => LLVM.IntW w }
Equations
- InstCombine.instCoeIntToTypeTy ty = { coe := fun (z : ℤ) => match ty with | InstCombine.MTy.bitvec (ConcreteOrMVar.concrete w) => some (BitVec.ofInt w z) }
Equations
- InstCombine.instInhabitedToTypeTy (InstCombine.MTy.bitvec (ConcreteOrMVar.concrete w)) = { default := pure default }
Homogeneous, unary operations
Instances For
Equations
- InstCombine.MOp.instReprUnaryOp = { reprPrec := InstCombine.MOp.reprUnaryOp✝ }
Equations
- InstCombine.MOp.instDecidableEqUnaryOp x y = if h : x.toCtorIdx = y.toCtorIdx then isTrue ⋯ else isFalse ⋯
Equations
- InstCombine.MOp.instInhabitedUnaryOp = { default := InstCombine.MOp.UnaryOp.neg }
Homogeneous, binary operations
- and: InstCombine.MOp.BinaryOp
- or: optParam LLVM.DisjointFlag { disjoint := false } → InstCombine.MOp.BinaryOp
- xor: InstCombine.MOp.BinaryOp
- shl: optParam LLVM.NoWrapFlags { nsw := false, nuw := false } → InstCombine.MOp.BinaryOp
- lshr: optParam LLVM.ExactFlag { exact := false } → InstCombine.MOp.BinaryOp
- ashr: optParam LLVM.ExactFlag { exact := false } → InstCombine.MOp.BinaryOp
- urem: InstCombine.MOp.BinaryOp
- srem: InstCombine.MOp.BinaryOp
- add: optParam LLVM.NoWrapFlags { nsw := false, nuw := false } → InstCombine.MOp.BinaryOp
- mul: optParam LLVM.NoWrapFlags { nsw := false, nuw := false } → InstCombine.MOp.BinaryOp
- sub: optParam LLVM.NoWrapFlags { nsw := false, nuw := false } → InstCombine.MOp.BinaryOp
- sdiv: optParam LLVM.ExactFlag { exact := false } → InstCombine.MOp.BinaryOp
- udiv: optParam LLVM.ExactFlag { exact := false } → InstCombine.MOp.BinaryOp
Instances For
Equations
- InstCombine.MOp.instInhabitedBinaryOp = { default := InstCombine.MOp.BinaryOp.and }
If both the nuw and nsw flags are the default value (false,false), then we should not print them. This should be the default behavior in Lean, but it isn't
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- InstCombine.instReprBinaryOp = { reprPrec := InstCombine.reprWithoutFlags }
- unary: {φ : ℕ} → InstCombine.Width φ → InstCombine.MOp.UnaryOp → InstCombine.MOp φ
- binary: {φ : ℕ} → InstCombine.Width φ → InstCombine.MOp.BinaryOp → InstCombine.MOp φ
- select: {φ : ℕ} → InstCombine.Width φ → InstCombine.MOp φ
- icmp: {φ : ℕ} → LLVM.IntPredicate → InstCombine.Width φ → InstCombine.MOp φ
- const: {φ : ℕ} → InstCombine.Width φ → ℤ → InstCombine.MOp φ
Since the width of the const might not be known, we just store the value as an
Int
Instances For
Equations
- InstCombine.instReprMOp = { reprPrec := InstCombine.reprMOp✝ }
Equations
- InstCombine.instDecidableEqMOp = InstCombine.decEqMOp✝
Equations
- InstCombine.instInhabitedMOp = { default := InstCombine.MOp.unary default default }
Instances For
Instances For
Instances For
Instances For
Instances For
Instances For
Instances For
Equations
- InstCombine.MOp.or w DisjointFlag = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.or DisjointFlag)
Instances For
Equations
- InstCombine.MOp.shl w NoWrapFlags = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.shl NoWrapFlags)
Instances For
Equations
- InstCombine.MOp.add w NoWrapFlags = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.add NoWrapFlags)
Instances For
Equations
- InstCombine.MOp.mul w NoWrapFlags = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.mul NoWrapFlags)
Instances For
Equations
- InstCombine.MOp.sub w NoWrapFlags = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.sub NoWrapFlags)
Instances For
Equations
- InstCombine.MOp.lshr w ExactFlag = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.lshr ExactFlag)
Instances For
Equations
- InstCombine.MOp.ashr w ExactFlag = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.ashr ExactFlag)
Instances For
Equations
- InstCombine.MOp.sdiv w ExactFlag = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.sdiv ExactFlag)
Instances For
Equations
- InstCombine.MOp.udiv w ExactFlag = InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.udiv ExactFlag)
Instances For
Recursion principle in terms of individual operations, rather than unary
or binary
Equations
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.unary w InstCombine.MOp.UnaryOp.neg) = neg
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.unary w InstCombine.MOp.UnaryOp.not) = not
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.unary w InstCombine.MOp.UnaryOp.copy) = copy
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w InstCombine.MOp.BinaryOp.and) = and
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.or disjoint)) = or
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w InstCombine.MOp.BinaryOp.xor) = xor
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.shl nswnuw)) = shl
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.lshr exact)) = lshr
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.ashr exact)) = ashr
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w InstCombine.MOp.BinaryOp.urem) = urem
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w InstCombine.MOp.BinaryOp.srem) = srem
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.add nswnuw)) = add
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.mul nswnuw)) = mul
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.sub nswnuw)) = sub
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.sdiv exact)) = sdiv
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.binary w (InstCombine.MOp.BinaryOp.udiv exact)) = udiv
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.select w) = select
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.icmp c w) = icmp
- InstCombine.MOp.deepCasesOn neg not copy and or xor shl lshr ashr urem srem add mul sub sdiv udiv select icmp const (InstCombine.MOp.const w val) = const
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
- InstCombine.Op.and = InstCombine.MOp.and ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.not = InstCombine.MOp.not ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.xor = InstCombine.MOp.xor ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.urem = InstCombine.MOp.urem ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.srem = InstCombine.MOp.srem ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.select = InstCombine.MOp.select ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.neg = InstCombine.MOp.neg ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.copy = InstCombine.MOp.copy ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.icmp c = InstCombine.MOp.icmp c ∘ ConcreteOrMVar.concrete
Instances For
Equations
- InstCombine.Op.const w val = InstCombine.MOp.const (ConcreteOrMVar.concrete w) val
Instances For
Equations
- InstCombine.Op.or w flag = InstCombine.MOp.or (ConcreteOrMVar.concrete w) flag
Instances For
Equations
- InstCombine.Op.shl w flags = InstCombine.MOp.shl (ConcreteOrMVar.concrete w) flags
Instances For
Equations
- InstCombine.Op.add w flags = InstCombine.MOp.add (ConcreteOrMVar.concrete w) flags
Instances For
Equations
- InstCombine.Op.mul w flags = InstCombine.MOp.mul (ConcreteOrMVar.concrete w) flags
Instances For
Equations
- InstCombine.Op.sub w flags = InstCombine.MOp.sub (ConcreteOrMVar.concrete w) flags
Instances For
Equations
- InstCombine.Op.lshr w flag = InstCombine.MOp.lshr (ConcreteOrMVar.concrete w) flag
Instances For
Equations
- InstCombine.Op.ashr w flag = InstCombine.MOp.ashr (ConcreteOrMVar.concrete w) flag
Instances For
Equations
- InstCombine.Op.sdiv w flag = InstCombine.MOp.sdiv (ConcreteOrMVar.concrete w) flag
Instances For
Equations
- InstCombine.Op.udiv w flag = InstCombine.MOp.udiv (ConcreteOrMVar.concrete w) flag
Instances For
Equations
- InstCombine.instToStringOp = { toString := fun (o : InstCombine.Op) => (repr o).pretty }
Equations
- (InstCombine.MOp.binary w op).sig = [InstCombine.MTy.bitvec w, InstCombine.MTy.bitvec w]
- (InstCombine.MOp.icmp c w).sig = [InstCombine.MTy.bitvec w, InstCombine.MTy.bitvec w]
- (InstCombine.MOp.unary w op).sig = [InstCombine.MTy.bitvec w]
- (InstCombine.MOp.select w).sig = [InstCombine.MTy.bitvec 1, InstCombine.MTy.bitvec w, InstCombine.MTy.bitvec w]
- (InstCombine.MOp.const w val).sig = []
Instances For
Equations
- (InstCombine.MOp.binary w op).outTy = InstCombine.MTy.bitvec w
- (InstCombine.MOp.unary w op).outTy = InstCombine.MTy.bitvec w
- (InstCombine.MOp.select w).outTy = InstCombine.MTy.bitvec w
- (InstCombine.MOp.const w val).outTy = InstCombine.MTy.bitvec w
- (InstCombine.MOp.icmp c w).outTy = InstCombine.MTy.bitvec 1
Instances For
MetaLLVM φ
is the LLVM
dialect with at most φ
metavariables
Equations
- InstCombine.MetaLLVM φ = { Op := InstCombine.MOp φ, Ty := InstCombine.MTy φ, m := Id }
Instances For
Equations
- InstCombine.LLVM = { Op := InstCombine.Op, Ty := InstCombine.Ty, m := Id }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
- InstCombine.Op.denote (InstCombine.MOp.const (ConcreteOrMVar.concrete a) val) op_2 = LLVM.const? val
- InstCombine.Op.denote (InstCombine.MOp.unary (ConcreteOrMVar.concrete a) InstCombine.MOp.UnaryOp.copy) op_2 = op_2.getN 0 InstCombine.Op.denote.proof_1
- InstCombine.Op.denote (InstCombine.MOp.unary (ConcreteOrMVar.concrete a) InstCombine.MOp.UnaryOp.not) op_2 = LLVM.not (op_2.getN 0 InstCombine.Op.denote.proof_1)
- InstCombine.Op.denote (InstCombine.MOp.unary (ConcreteOrMVar.concrete a) InstCombine.MOp.UnaryOp.neg) op_2 = LLVM.neg (op_2.getN 0 InstCombine.Op.denote.proof_1)
- InstCombine.Op.denote (InstCombine.MOp.icmp c (ConcreteOrMVar.concrete a)) op_2 = LLVM.icmp c (op_2.getN 0 InstCombine.Op.denote.proof_2) (op_2.getN 1 InstCombine.Op.denote.proof_3)
Instances For
Equations
- One or more equations did not get rendered due to their size.