Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/backend/analysis/address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace rat {
return n->getType() && n->getType()->isInt() && n->getType()->getIntWidth() == 64;
}

bool termLess(const Pair<const Node*, I64>& a, const Pair<const Node*, I64>& b) {
B32 termLess(const Pair<const Node*, I64>& a, const Pair<const Node*, I64>& b) {
return a.first->getId() < b.first->getId();
}

Expand Down
8 changes: 4 additions & 4 deletions src/backend/ir/text_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ namespace rat {
if(lhs.empty() || lhs[0] != 'v' || !allDigits(lhs.substr(1)))
return fail("bad result name '" + lhs + "'");
errno = 0;
unsigned long idv = std::strtoul(lhs.c_str() + 1, nullptr, 10);
U64 idv = std::strtoul(lhs.c_str() + 1, nullptr, 10);
if(errno == ERANGE || idv > 0xffffffffUL)
return fail("result id out of range '" + lhs + "'");
pn.id = (U32)idv;
Expand Down Expand Up @@ -366,7 +366,7 @@ namespace rat {
if(remainder.empty())
return fail("constant is missing its value: " + line);
errno = 0;
char* cend = nullptr;
C8* cend = nullptr;
pn.cval = (I64)std::strtoll(remainder.c_str(), &cend, 10);
if(cend == remainder.c_str() || errno == ERANGE)
return fail("bad constant value '" + remainder + "'");
Expand All @@ -383,7 +383,7 @@ namespace rat {
if(!allDigits(toks[0].substr(1)))
return fail("bad proj index '" + toks[0] + "'");
errno = 0;
unsigned long pj = std::strtoul(toks[0].c_str() + 1, nullptr, 10);
U64 pj = std::strtoul(toks[0].c_str() + 1, nullptr, 10);
if(errno == ERANGE || pj > 0xffffffffUL)
return fail("proj index out of range '" + toks[0] + "'");
pn.projIndex = (U32)pj;
Expand Down Expand Up @@ -447,7 +447,7 @@ namespace rat {
if(laneTok.size() < 2 || laneTok[0] != '#' || !allDigits(laneTok.substr(1)))
return fail("malformed lane selector (expected #index): " + line);
errno = 0;
unsigned long lane = std::strtoul(laneTok.c_str() + 1, nullptr, 10);
U64 lane = std::strtoul(laneTok.c_str() + 1, nullptr, 10);
if(errno == ERANGE || lane > 0xffffffffUL)
return fail("lane selector out of range: " + line);
pn.projIndex = (U32)lane; // reuse the proj payload slot for the selector
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pass/emit/x86/x86_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ namespace rat {
U32 instCount = 0;
for(const MachineBlock& blk : mf.blocks)
instCount += (U32)blk.insts.size();
code.reserve((size_t)instCount * 16u + 64u); // cheap upper estimate
code.reserve((U64)instCount * 16u + 64u); // cheap upper estimate

Asm a(code, relocs);
reset(mf, fl, a, mf.usedCalleeSaved);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pass/emit/x86/x86_lower_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ namespace rat {
h ^= x;
h *= 1099511628211ull;
}
std::snprintf(buf, sizeof buf, "__rat_vec_%016llx", (unsigned long long)h);
std::snprintf(buf, sizeof buf, "__rat_vec_%016lx", (U64)h);
String name(buf);
if(!mod->getGlobal(name)) {
List<U8> init = bytes;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pass/opt/fold.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace rat {
static B32 matchVarConst(Node* n, Opcode want, Node*& base, I64& c);
private:
List<Node*> work;
List<char> queued;
List<C8> queued;
List<Node*> stack;
};
} // namespace rat
Expand Down
4 changes: 2 additions & 2 deletions src/backend/pass/opt/gvn.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace rat {
};

struct GVNKeyHash {
size_t operator()(const GVNKey& k) const {
U64 operator()(const GVNKey& k) const {
U64 h = 1469598103934665603ull;
auto mix = [&](U64 v) {
h ^= v;
Expand All @@ -44,7 +44,7 @@ namespace rat {
mix(((U64)k.in1) << 32);
if(k.sym)
mix(std::hash<String>{}(*k.sym));
return (size_t)h;
return (U64)h;
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/backend/pass/opt/sccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace rat {
U32 rewrite(Function& fn);
private:
List<Lattice> values; // lattice for value producing nodes, Top when unset
List<char> exec; // control nodes proven executable
List<C8> exec; // control nodes proven executable
List<Node*> flowWork; // executable control nodes to propagate
List<Node*> ssaWork; // value / if nodes to re-evaluate
};
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pass/opt/slp/slp_packer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ namespace rat {
// each broadcast then picks its lane in-register instead of touching memory
void slp::Packer::coalesceSplats() {
struct Cand {
bool operator<(const Cand& o) const {
B32 operator<(const Cand& o) const {
if(sig != o.sig)
return sig < o.sig;
return c < o.c;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pass/opt/slp/slp_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace rat {
// canonical term order: sort by the first leaf load's refined address so
// grouping is robust against source-level reassociation
struct Keyed {
bool operator<(const Keyed& o) const {
B32 operator<(const Keyed& o) const {
if(sig != o.sig)
return sig < o.sig;
return c < o.c;
Expand Down
1 change: 1 addition & 0 deletions src/base/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace rat {

using F32 = float;
using F64 = double;
using F80 = long double;

using C8 = char;
using B32 = uint32_t;
Expand Down
6 changes: 3 additions & 3 deletions src/base/test_harness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

namespace rat {
namespace detail {
B32 hasSuffix(const String& s, const char* suffix) {
B32 hasSuffix(const String& s, const C8* suffix) {
String suf = suffix;
return s.size() >= suf.size() && s.compare(s.size() - suf.size(), suf.size(), suf) == 0;
}

void collectCases(const String& dir, const char* ext, List<String>& out) {
void collectCases(const String& dir, const C8* ext, List<String>& out) {
std::error_code ec;
List<String> subdirs;
List<String> files;
Expand Down Expand Up @@ -40,7 +40,7 @@ namespace rat {
}
} // namespace detail

I32 runTestSuite(I32 argc, char** argv, const TestSuiteSpec& spec) {
I32 runTestSuite(I32 argc, C8** argv, const TestSuiteSpec& spec) {
U32 jobs = 1;
B32 quiet = false; // -q: only the per-case lines, the caller tallies them
List<String> cases;
Expand Down
10 changes: 5 additions & 5 deletions src/base/test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

namespace rat {
namespace detail {
B32 hasSuffix(const String& s, const char* suffix);
void collectCases(const String& dir, const char* ext, List<String>& out);
B32 hasSuffix(const String& s, const C8* suffix);
void collectCases(const String& dir, const C8* ext, List<String>& out);
String findDir(const List<String>& candidates);
} // namespace detail

using CaseRunner = Delegate<B32(const String& path, String& err)>;

struct TestSuiteSpec {
const char* tool; // program name
const char* extension; // case file suffix
const C8* tool; // program name
const C8* extension; // case file suffix
List<String> dirCandidates; // searched when no paths are given
CaseRunner run; // executes a single case
};

I32 runTestSuite(I32 argc, char** argv, const TestSuiteSpec& spec);
I32 runTestSuite(I32 argc, C8** argv, const TestSuiteSpec& spec);
} // namespace rat

#endif
4 changes: 2 additions & 2 deletions src/compiler/emit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ namespace rat::cc {
B32 evalConstTyped(const Expr* expr, I64& out, CType& ty);
B32 evalConstUnary(ExprOp op, I64 v, CType opTy, I64& out, CType& ty);
B32 evalConstBinary(ExprOp op, I64 a, CType aTy, I64 b, CType bTy, I64& out, CType& ty);
B32 evalFloatConst(const Expr* expr, long double& out);
void encodeFloatBytes(CType dt, long double v, List<U8>& out);
B32 evalFloatConst(const Expr* expr, F80& out);
void encodeFloatBytes(CType dt, F80 v, List<U8>& out);
B32 evalAddrConst(const Expr* expr, String& symbol, I64& addend);
B32 addrConstOf(const Expr* lv, String& symbol, I64& addend);
String internString(const Expr* strLit);
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/emit/emit_const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace rat::cc {
return false;
CType opTy;
if(!evalConstTyped(e->cast.operand, out, opTy)) {
long double fv;
F80 fv;
if(isFloating(ty) || isPointer(ty) || isAggregate(ty) || ty.isVoid())
return false;
if(!evalFloatConst(e->cast.operand, fv))
Expand Down Expand Up @@ -211,12 +211,12 @@ namespace rat::cc {
return evalConstTyped(e, out, ty);
}

B32 Emitter::evalFloatConst(const Expr* e, long double& out) {
B32 Emitter::evalFloatConst(const Expr* e, F80& out) {
if(e->kind == ExprKind::IntLit || e->kind == ExprKind::Cast) {
I64 iv;
CType it;
if(evalConstTyped(e, iv, it) && isInteger(it)) {
out = it.isUnsigned() ? (long double)(U64)iv : (long double)iv;
out = it.isUnsigned() ? (F80)(U64)iv : (F80)iv;
return true;
}
}
Expand All @@ -227,7 +227,7 @@ namespace rat::cc {
case ExprKind::Cast:
return evalFloatConst(e->cast.operand, out);
case ExprKind::Unary: {
long double v;
F80 v;
if(!evalFloatConst(e->unary.operand, v))
return false;
switch(e->unary.op) {
Expand All @@ -242,7 +242,7 @@ namespace rat::cc {
}
}
case ExprKind::Binary: {
long double a, b;
F80 a, b;
if(!evalFloatConst(e->binary.lhs, a) || !evalFloatConst(e->binary.rhs, b))
return false;
switch(e->binary.op) {
Expand All @@ -268,7 +268,7 @@ namespace rat::cc {
if(evalConst(e->ternary.cond, ci)) {
taken = ci != 0;
} else {
long double cf;
F80 cf;
if(!evalFloatConst(e->ternary.cond, cf))
return false;
taken = cf != 0;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/emit/emit_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace rat::cc {
CType t;
t.base = CType::Base::Float;
t.bits = e->floatLit.bits;
Node* lit = fn.constFloat(irType(t), (double)e->floatLit.value);
Node* lit = fn.constFloat(irType(t), (F64)e->floatLit.value);
if(e->floatLit.imaginary) {
CType ct = t;
ct.set(CType::Complex);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/emit/emit_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace rat::cc {
String name = "__ratcc_str" + std::to_string(strCounter++);
List<U8> init;
init.reserve(bytes.size() + cw);
for(char c : bytes)
for(C8 c : bytes)
init.push_back((U8)c);
for(U32 i = 0; i < cw; ++i)
init.push_back(0);
Expand Down Expand Up @@ -288,7 +288,7 @@ namespace rat::cc {
List<U8> fbytes;
if(dinit) {
if(isFloating(d.type)) {
long double dv = 0;
F80 dv = 0;
if(!evalFloatConst(dinit, dv)) {
fail("initializer for '" + *d.name + "' is not a constant expression");
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/emit/emit_init_flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,21 @@ namespace rat::cc {
return true;
}

void Emitter::encodeFloatBytes(CType dt, long double v, List<U8>& out) {
void Emitter::encodeFloatBytes(CType dt, F80 v, List<U8>& out) {
if(dt.bits == 32) {
float f = (float)v;
F32 f = (F32)v;
const U8* p = (const U8*)&f;
for(U32 i = 0; i < sizeof(f); ++i)
out.push_back(p[i]);
} else if(dt.bits == 128) {
// x86 extended precision
long double ld = v;
F80 ld = v;
const U8* p = (const U8*)&ld;
U32 n = byteSize(dt); // 16
for(U32 i = 0; i < n; ++i)
out.push_back(i < 10 ? p[i] : (U8)0);
} else {
double d = (double)v;
F64 d = (F64)v;
const U8* p = (const U8*)&d;
for(U32 i = 0; i < sizeof(d); ++i)
out.push_back(p[i]);
Expand All @@ -185,7 +185,7 @@ namespace rat::cc {
return true;
U64 bits = 0;
if(isFloating(dt)) {
long double d = 0;
F80 d = 0;
if(!emit.evalFloatConst(e, d)) {
emit.failNonConstInit();
return false;
Expand Down
Loading
Loading