Commit 3069669bc1

David Rubin <daviru007@icloud.com>
2024-02-06 02:05:20
add the `clflush` mnem
1 parent 0c80725
Changed files (4)
src/arch/x86_64/CodeGen.zig
@@ -12475,6 +12475,7 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
             break :mnem std.meta.stringToEnum(Instruction.Mnemonic, mnem_str);
         } orelse return self.fail("invalid mnemonic: '{s}'", .{mnem_str});
         if (@as(?Memory.Size, switch (mnem_tag) {
+            .clflush => .byte,
             .fldenv, .fnstenv, .fstenv => .none,
             .ldmxcsr, .stmxcsr, .vldmxcsr, .vstmxcsr => .dword,
             else => null,
src/arch/x86_64/Encoding.zig
@@ -224,7 +224,7 @@ pub const Mnemonic = enum {
     // General-purpose
     adc, add, @"and",
     bsf, bsr, bswap, bt, btc, btr, bts,
-    call, cbw, cdq, cdqe,
+    call, cbw, cdq, cdqe, clflush,
     cmova, cmovae, cmovb, cmovbe, cmovc, cmove, cmovg, cmovge, cmovl, cmovle, cmovna,
     cmovnae, cmovnb, cmovnbe, cmovnc, cmovne, cmovng, cmovnge, cmovnl, cmovnle, cmovno,
     cmovnp, cmovns, cmovnz, cmovo, cmovp, cmovpe, cmovpo, cmovs, cmovz,
src/arch/x86_64/encodings.zig
@@ -132,6 +132,8 @@ pub const table = [_]Entry{
     .{ .cdq, .zo, &.{ .o32 }, &.{ 0x99 }, 0, .none,  .none },
     .{ .cqo, .zo, &.{ .o64 }, &.{ 0x99 }, 0, .long,  .none },
 
+    .{ .clflush, .m, &.{ .m8 }, &.{ 0x0f, 0xae }, 7, .none, .none },
+
     .{ .cmova,   .rm, &.{ .r16, .rm16 }, &.{ 0x0f, 0x47 }, 0, .short, .none },
     .{ .cmova,   .rm, &.{ .r32, .rm32 }, &.{ 0x0f, 0x47 }, 0, .none,  .none },
     .{ .cmova,   .rm, &.{ .r64, .rm64 }, &.{ 0x0f, 0x47 }, 0, .long,  .none },
src/arch/x86_64/Mir.zig
@@ -305,6 +305,8 @@ pub const Inst = struct {
         cdq,
         /// Convert doubleword to quadword
         cdqe,
+        /// Flush cache line
+        clflush,
         /// Conditional move
         cmov,
         /// Logical compare