commit dacee5fd166029c4f64c7929dc9064418c739d40
parent 401b9d545afdde914f13ae1ee0d2f99c89b527d6
Author: erai <erai@omiltem.net>
Date: Tue, 21 May 2024 04:09:46 -0400
add rdrand
Diffstat:
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/as.c b/as.c
@@ -115,6 +115,8 @@ enum {
OP_ORI = 0x010081,
OP_CMPI = 0x070081,
+ OP_RDRAND = 0x060fc7,
+
OP_IMULM = 0x0400f7,
OP_IDIVM = 0x0700f7,
OP_SHLM = 0x0400d3,
diff --git a/cc1.c b/cc1.c
@@ -1895,6 +1895,15 @@ main(argc: int, argv: **byte, envp: **byte) {
emit_ret(c.as);
}
+ d = find(c, "_rdrand", 0:*byte, 1);
+ if (d.func_defined && !d.func_label.fixed) {
+ fixup_label(c.as, d.func_label);
+ emit_preamble(c.as, 0, 0);
+ as_modr(c.as, OP_RDRAND, R_RAX);
+ as_opr(c.as, OP_PUSHR, R_RAX);
+ emit_ret(c.as);
+ }
+
d = find(c, "taskswitch", 0:*byte, 1);
if (d.func_defined && !d.func_label.fixed) {
fixup_label(c.as, d.func_label);