add@"add nsw"@"add nuw"@"add nuw nsw"addrspacecastalloca@"alloca inalloca"@"and"ashr@"ashr exact"atomicrmwbitcastblockbrbr_condcall@"call fast"cmpxchg@"cmpxchg weak"extractelementextractvaluefadd@"fadd fast"@"fcmp false"@"fcmp fast false"@"fcmp fast oeq"@"fcmp fast oge"@"fcmp fast ogt"@"fcmp fast ole"@"fcmp fast olt"@"fcmp fast one"@"fcmp fast ord"@"fcmp fast true"@"fcmp fast ueq"@"fcmp fast uge"@"fcmp fast ugt"@"fcmp fast ule"@"fcmp fast ult"@"fcmp fast une"@"fcmp fast uno"@"fcmp oeq"@"fcmp oge"@"fcmp ogt"@"fcmp ole"@"fcmp olt"@"fcmp one"@"fcmp ord"@"fcmp true"@"fcmp ueq"@"fcmp uge"@"fcmp ugt"@"fcmp ule"@"fcmp ult"@"fcmp une"@"fcmp uno"fdiv@"fdiv fast"fencefmul@"fmul fast"fneg@"fneg fast"fpextfptosifptouifptruncfrem@"frem fast"fsub@"fsub fast"getelementptr@"getelementptr inbounds"@"icmp eq"@"icmp ne"@"icmp sge"@"icmp sgt"@"icmp sle"@"icmp slt"@"icmp uge"@"icmp ugt"@"icmp ule"@"icmp ult"indirectbrinsertelementinsertvalueinttoptrload@"load atomic"lshr@"lshr exact"mul@"mul nsw"@"mul nuw"@"mul nuw nsw"@"musttail call"@"musttail call fast"@"notail call"@"notail call fast"@"or"phi@"phi fast"ptrtointret@"ret void"sdiv@"sdiv exact"select@"select fast"sextshl@"shl nsw"@"shl nuw"@"shl nuw nsw"shufflevectorsitofpsremstore@"store atomic"sub@"sub nsw"@"sub nuw"@"sub nuw nsw"@"switch"@"tail call"@"tail call fast"truncudiv@"udiv exact"uremuitofp@"unreachable"va_argxorzextpub fn toBinaryOpcode(self: Tag) BinaryOpcodeself: Tagpub fn toBinaryOpcode(self: Tag) BinaryOpcode {
return switch (self) {
.add,
.@"add nsw",
.@"add nuw",
.@"add nuw nsw",
.fadd,
.@"fadd fast",
=> .add,
.sub,
.@"sub nsw",
.@"sub nuw",
.@"sub nuw nsw",
.fsub,
.@"fsub fast",
=> .sub,
.sdiv,
.@"sdiv exact",
.fdiv,
.@"fdiv fast",
=> .sdiv,
.fmul,
.@"fmul fast",
.mul,
.@"mul nsw",
.@"mul nuw",
.@"mul nuw nsw",
=> .mul,
.srem,
.frem,
.@"frem fast",
=> .srem,
.udiv,
.@"udiv exact",
=> .udiv,
.shl,
.@"shl nsw",
.@"shl nuw",
.@"shl nuw nsw",
=> .shl,
.lshr,
.@"lshr exact",
=> .lshr,
.ashr,
.@"ashr exact",
=> .ashr,
.@"and" => .@"and",
.@"or" => .@"or",
.xor => .xor,
.urem => .urem,
else => unreachable,
};
}pub fn toCastOpcode(self: Tag) CastOpcodeself: Tagpub fn toCastOpcode(self: Tag) CastOpcode {
return switch (self) {
.trunc => .trunc,
.zext => .zext,
.sext => .sext,
.fptoui => .fptoui,
.fptosi => .fptosi,
.uitofp => .uitofp,
.sitofp => .sitofp,
.fptrunc => .fptrunc,
.fpext => .fpext,
.ptrtoint => .ptrtoint,
.inttoptr => .inttoptr,
.bitcast => .bitcast,
.addrspacecast => .addrspacecast,
else => unreachable,
};
}pub fn toCmpPredicate(self: Tag) CmpPredicateself: Tagpub fn toCmpPredicate(self: Tag) CmpPredicate {
return switch (self) {
.@"fcmp false",
.@"fcmp fast false",
=> .fcmp_false,
.@"fcmp oeq",
.@"fcmp fast oeq",
=> .fcmp_oeq,
.@"fcmp oge",
.@"fcmp fast oge",
=> .fcmp_oge,
.@"fcmp ogt",
.@"fcmp fast ogt",
=> .fcmp_ogt,
.@"fcmp ole",
.@"fcmp fast ole",
=> .fcmp_ole,
.@"fcmp olt",
.@"fcmp fast olt",
=> .fcmp_olt,
.@"fcmp one",
.@"fcmp fast one",
=> .fcmp_one,
.@"fcmp ord",
.@"fcmp fast ord",
=> .fcmp_ord,
.@"fcmp true",
.@"fcmp fast true",
=> .fcmp_true,
.@"fcmp ueq",
.@"fcmp fast ueq",
=> .fcmp_ueq,
.@"fcmp uge",
.@"fcmp fast uge",
=> .fcmp_uge,
.@"fcmp ugt",
.@"fcmp fast ugt",
=> .fcmp_ugt,
.@"fcmp ule",
.@"fcmp fast ule",
=> .fcmp_ule,
.@"fcmp ult",
.@"fcmp fast ult",
=> .fcmp_ult,
.@"fcmp une",
.@"fcmp fast une",
=> .fcmp_une,
.@"fcmp uno",
.@"fcmp fast uno",
=> .fcmp_uno,
.@"icmp eq" => .icmp_eq,
.@"icmp ne" => .icmp_ne,
.@"icmp sge" => .icmp_sge,
.@"icmp sgt" => .icmp_sgt,
.@"icmp sle" => .icmp_sle,
.@"icmp slt" => .icmp_slt,
.@"icmp uge" => .icmp_uge,
.@"icmp ugt" => .icmp_ugt,
.@"icmp ule" => .icmp_ule,
.@"icmp ult" => .icmp_ult,
else => unreachable,
};
}pub const Tag = enum(u8) {
add,
@"add nsw",
@"add nuw",
@"add nuw nsw",
addrspacecast,
alloca,
@"alloca inalloca",
@"and",
arg,
ashr,
@"ashr exact",
atomicrmw,
bitcast,
block,
br,
br_cond,
call,
@"call fast",
cmpxchg,
@"cmpxchg weak",
extractelement,
extractvalue,
fadd,
@"fadd fast",
@"fcmp false",
@"fcmp fast false",
@"fcmp fast oeq",
@"fcmp fast oge",
@"fcmp fast ogt",
@"fcmp fast ole",
@"fcmp fast olt",
@"fcmp fast one",
@"fcmp fast ord",
@"fcmp fast true",
@"fcmp fast ueq",
@"fcmp fast uge",
@"fcmp fast ugt",
@"fcmp fast ule",
@"fcmp fast ult",
@"fcmp fast une",
@"fcmp fast uno",
@"fcmp oeq",
@"fcmp oge",
@"fcmp ogt",
@"fcmp ole",
@"fcmp olt",
@"fcmp one",
@"fcmp ord",
@"fcmp true",
@"fcmp ueq",
@"fcmp uge",
@"fcmp ugt",
@"fcmp ule",
@"fcmp ult",
@"fcmp une",
@"fcmp uno",
fdiv,
@"fdiv fast",
fence,
fmul,
@"fmul fast",
fneg,
@"fneg fast",
fpext,
fptosi,
fptoui,
fptrunc,
frem,
@"frem fast",
fsub,
@"fsub fast",
getelementptr,
@"getelementptr inbounds",
@"icmp eq",
@"icmp ne",
@"icmp sge",
@"icmp sgt",
@"icmp sle",
@"icmp slt",
@"icmp uge",
@"icmp ugt",
@"icmp ule",
@"icmp ult",
indirectbr,
insertelement,
insertvalue,
inttoptr,
load,
@"load atomic",
lshr,
@"lshr exact",
mul,
@"mul nsw",
@"mul nuw",
@"mul nuw nsw",
@"musttail call",
@"musttail call fast",
@"notail call",
@"notail call fast",
@"or",
phi,
@"phi fast",
ptrtoint,
ret,
@"ret void",
sdiv,
@"sdiv exact",
select,
@"select fast",
sext,
shl,
@"shl nsw",
@"shl nuw",
@"shl nuw nsw",
shufflevector,
sitofp,
srem,
store,
@"store atomic",
sub,
@"sub nsw",
@"sub nuw",
@"sub nuw nsw",
@"switch",
@"tail call",
@"tail call fast",
trunc,
udiv,
@"udiv exact",
urem,
uitofp,
@"unreachable",
va_arg,
xor,
zext,
pub fn toBinaryOpcode(self: Tag) BinaryOpcode {
return switch (self) {
.add,
.@"add nsw",
.@"add nuw",
.@"add nuw nsw",
.fadd,
.@"fadd fast",
=> .add,
.sub,
.@"sub nsw",
.@"sub nuw",
.@"sub nuw nsw",
.fsub,
.@"fsub fast",
=> .sub,
.sdiv,
.@"sdiv exact",
.fdiv,
.@"fdiv fast",
=> .sdiv,
.fmul,
.@"fmul fast",
.mul,
.@"mul nsw",
.@"mul nuw",
.@"mul nuw nsw",
=> .mul,
.srem,
.frem,
.@"frem fast",
=> .srem,
.udiv,
.@"udiv exact",
=> .udiv,
.shl,
.@"shl nsw",
.@"shl nuw",
.@"shl nuw nsw",
=> .shl,
.lshr,
.@"lshr exact",
=> .lshr,
.ashr,
.@"ashr exact",
=> .ashr,
.@"and" => .@"and",
.@"or" => .@"or",
.xor => .xor,
.urem => .urem,
else => unreachable,
};
}
pub fn toCastOpcode(self: Tag) CastOpcode {
return switch (self) {
.trunc => .trunc,
.zext => .zext,
.sext => .sext,
.fptoui => .fptoui,
.fptosi => .fptosi,
.uitofp => .uitofp,
.sitofp => .sitofp,
.fptrunc => .fptrunc,
.fpext => .fpext,
.ptrtoint => .ptrtoint,
.inttoptr => .inttoptr,
.bitcast => .bitcast,
.addrspacecast => .addrspacecast,
else => unreachable,
};
}
pub fn toCmpPredicate(self: Tag) CmpPredicate {
return switch (self) {
.@"fcmp false",
.@"fcmp fast false",
=> .fcmp_false,
.@"fcmp oeq",
.@"fcmp fast oeq",
=> .fcmp_oeq,
.@"fcmp oge",
.@"fcmp fast oge",
=> .fcmp_oge,
.@"fcmp ogt",
.@"fcmp fast ogt",
=> .fcmp_ogt,
.@"fcmp ole",
.@"fcmp fast ole",
=> .fcmp_ole,
.@"fcmp olt",
.@"fcmp fast olt",
=> .fcmp_olt,
.@"fcmp one",
.@"fcmp fast one",
=> .fcmp_one,
.@"fcmp ord",
.@"fcmp fast ord",
=> .fcmp_ord,
.@"fcmp true",
.@"fcmp fast true",
=> .fcmp_true,
.@"fcmp ueq",
.@"fcmp fast ueq",
=> .fcmp_ueq,
.@"fcmp uge",
.@"fcmp fast uge",
=> .fcmp_uge,
.@"fcmp ugt",
.@"fcmp fast ugt",
=> .fcmp_ugt,
.@"fcmp ule",
.@"fcmp fast ule",
=> .fcmp_ule,
.@"fcmp ult",
.@"fcmp fast ult",
=> .fcmp_ult,
.@"fcmp une",
.@"fcmp fast une",
=> .fcmp_une,
.@"fcmp uno",
.@"fcmp fast uno",
=> .fcmp_uno,
.@"icmp eq" => .icmp_eq,
.@"icmp ne" => .icmp_ne,
.@"icmp sge" => .icmp_sge,
.@"icmp sgt" => .icmp_sgt,
.@"icmp sle" => .icmp_sle,
.@"icmp slt" => .icmp_slt,
.@"icmp uge" => .icmp_uge,
.@"icmp ugt" => .icmp_ugt,
.@"icmp ule" => .icmp_ule,
.@"icmp ult" => .icmp_ult,
else => unreachable,
};
}
}