aboutsummaryrefslogtreecommitdiff
path: root/rcc-legacy
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:07:09 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-06-08 17:07:09 +0800
commita4a5ad2786a1937addc09d72a375158877fb3b80 (patch)
tree0e31b7608545573a3b9d1c3e7454cc04679fe51b /rcc-legacy
parentf4126232d73bbcc1b9f8504a349f9a9913237616 (diff)
downloadrcc-project-a4a5ad2786a1937addc09d72a375158877fb3b80.tar.gz
rcc-project-a4a5ad2786a1937addc09d72a375158877fb3b80.tar.xz
[legacy/mid] Add target-independent ABI lowering
Diffstat (limited to 'rcc-legacy')
-rw-r--r--rcc-legacy/src/mid/abi.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/rcc-legacy/src/mid/abi.cc b/rcc-legacy/src/mid/abi.cc
new file mode 100644
index 0000000..c4924da
--- /dev/null
+++ b/rcc-legacy/src/mid/abi.cc
@@ -0,0 +1,45 @@
+/* Source code for RCC-Legacy.
+ Copyright (C) 2026 Richard Qin
+
+This file is part of RCC.
+
+RCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+RCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with RCC; see the file LICENSE. If not see
+<http://www.gnu.org/licenses/>. */
+
+/// @file abi.cc
+/// @brief elimsb - Eliminate ABI-level sub-word op variants (sb/ub/sh/uh for arg/par/ret).
+///
+/// See docs/abi.md for architectural notes.
+
+#include "rcc/all.h"
+
+namespace rcc {
+
+void elimsb(Fn* fn) {
+ for (Blk* b = fn->start; b; b = b->link) {
+ Ins* ie = b->ins + b->nins;
+ for (Ins* i = b->ins; i < ie; ++i) {
+ if (isargbh(i->op)) {
+ i->op = Oarg;
+ } else if (isparbh(i->op)) {
+ i->op = Opar;
+ }
+ }
+ if (isretbh(b->jmp.type)) {
+ b->jmp.type = Jretw;
+ }
+ }
+}
+
+} // namespace rcc