From add95b14f74e6dbe04a6efe98ff0f20424930b73 Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Tue, 3 Feb 2026 14:59:53 -0500 Subject: [willow]: initial frontend work, unit tests (#8) --- willow/lib/IR/Value.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 willow/lib/IR/Value.cpp (limited to 'willow/lib/IR/Value.cpp') diff --git a/willow/lib/IR/Value.cpp b/willow/lib/IR/Value.cpp new file mode 100644 index 0000000..13e029f --- /dev/null +++ b/willow/lib/IR/Value.cpp @@ -0,0 +1,27 @@ +#include +#include +#include + +std::ostream &operator<<(std::ostream &os, const willow::Value &v) { + using willow::ValueKind; + auto ty = v.getType(); + if (!v.isVoid()) + os << ty << " "; + + switch (v.getValueKind()) { + case ValueKind::Parameter: + [[fallthrough]]; + case ValueKind::Instruction: { + return os << "%" << v.getName(); + } + case ValueKind::BasicBlock: { + return os << "^" << v.getName(); + } + case ValueKind::Function: { + return os << "@" << v.getName(); + } + case ValueKind::Constant: { + return os << *static_cast(&v); + } + } +} -- cgit v1.2.3