summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMaximilian Stemmer-Grabow <mail@mxsg.de>2021-05-28 12:58:17 +0200
committerAndreas Fried <andreas.fried@kit.edu>2021-12-02 12:57:28 +0100
commit86622597e2358dd6301fed79c9a0366ac288555f (patch)
treef611614aba773ca1bf32c75920c5d9abff1ec508
parent9d5b6686e82f439cff1ac8d97821d45804a90036 (diff)
Add function to check for node compressibility in RISC-V
This can be used after register allocation is finished to collect information about which nodes' compression requirements were satisfied.
-rw-r--r--ir/be/riscv/riscv_compression.c30
-rw-r--r--ir/be/riscv/riscv_compression.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/ir/be/riscv/riscv_compression.c b/ir/be/riscv/riscv_compression.c
index 2fea9dc..1829c1c 100644
--- a/ir/be/riscv/riscv_compression.c
+++ b/ir/be/riscv/riscv_compression.c
@@ -194,3 +194,33 @@ static bool riscv_is_2addr_form(const ir_node *const node)
return rs1 == rd;
}
+
+bool riscv_is_compressible(const ir_node *const node)
+{
+ compression_req_t requirement = (compression_req_t)riscv_get_op_compression_requirements(node);
+
+ switch (requirement) {
+ case comp_req_unknown:
+ case comp_req_never:
+ return false;
+
+ case comp_req_always:
+ return true;
+
+ case comp_req_register_subset: {
+ const arch_register_t *rd = arch_get_irn_register_out(node, 0);
+ return riscv_register_is_compressible(rd);
+ }
+
+ case comp_req_2addr:
+ return riscv_is_2addr_form(node);
+
+ case comp_req_2addr_register_subset: {
+ const arch_register_t *rd = arch_get_irn_register_out(node, 0);
+ return riscv_register_is_compressible(rd) && riscv_is_2addr_form(node);
+ }
+
+ default:
+ return false;
+ }
+}
diff --git a/ir/be/riscv/riscv_compression.h b/ir/be/riscv/riscv_compression.h
index f3098cb..342f9c1 100644
--- a/ir/be/riscv/riscv_compression.h
+++ b/ir/be/riscv/riscv_compression.h
@@ -11,8 +11,10 @@
#ifndef FIRM_BE_RISCV_RISCV_COMPRESSION_H
#define FIRM_BE_RISCV_RISCV_COMPRESSION_H
+#include <stdbool.h>
#include "firm_types.h"
int riscv_get_op_compression_requirements(ir_node const *node);
+bool riscv_is_compressible(const ir_node *node);
#endif