mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
what is going on with clang format
This commit is contained in:
parent
4c2bd94fef
commit
f46acdf87a
|
@ -136,6 +136,7 @@ class Compiler {
|
|||
Val* compile_add(const goos::Object& form, const goos::Object& rest, Env* env);
|
||||
Val* compile_sub(const goos::Object& form, const goos::Object& rest, Env* env);
|
||||
Val* compile_mul(const goos::Object& form, const goos::Object& rest, Env* env);
|
||||
Val* compile_div(const goos::Object& form, const goos::Object& rest, Env* env);
|
||||
|
||||
// Function
|
||||
Val* compile_lambda(const goos::Object& form, const goos::Object& rest, Env* env);
|
||||
|
|
|
@ -221,4 +221,22 @@ class IR_IntegerMath : public IR {
|
|||
RegVal* m_arg;
|
||||
};
|
||||
|
||||
enum class FloatMathKind { DIV_SS };
|
||||
|
||||
class IR_FloatMath : public IR {
|
||||
public:
|
||||
IR_FloatMath(FloatMathKind kind, RegVal* dest, RegVal* arg);
|
||||
std::string print() override;
|
||||
RegAllocInstr to_rai() override;
|
||||
void do_codegen(emitter::ObjectGenerator* gen,
|
||||
const AllocationResult& allocs,
|
||||
emitter::IR_Record irec) override;
|
||||
FloatMathKind get_kind() const { return m_kind; }
|
||||
|
||||
protected:
|
||||
FloatMathKind m_kind;
|
||||
RegVal* m_dest;
|
||||
RegVal* m_arg;
|
||||
};
|
||||
|
||||
#endif // JAK_IR_H
|
||||
|
|
|
@ -101,7 +101,7 @@ static const std::unordered_map<
|
|||
{"+", &Compiler::compile_add},
|
||||
{"-", &Compiler::compile_sub},
|
||||
{"*", &Compiler::compile_mul},
|
||||
// {"/", &Compiler::compile_divide},
|
||||
{"/", &Compiler::compile_div},
|
||||
// {"shlv", &Compiler::compile_shlv},
|
||||
// {"shrv", &Compiler::compile_shrv},
|
||||
// {"sarv", &Compiler::compile_sarv},
|
||||
|
|
|
@ -203,4 +203,33 @@ Val* Compiler::compile_sub(const goos::Object& form, const goos::Object& rest, E
|
|||
}
|
||||
assert(false);
|
||||
return get_none();
|
||||
}
|
||||
|
||||
Val* Compiler::compile_div(const goos::Object& form, const goos::Object& rest, Env* env) {
|
||||
auto args = get_va(form, rest);
|
||||
if (!args.named.empty() || args.unnamed.size() != 2) {
|
||||
throw_compile_error(form, "Invalid / form");
|
||||
}
|
||||
|
||||
auto first_val = compile_error_guard(args.unnamed.at(0), env);
|
||||
auto first_type = first_val->type();
|
||||
auto math_type = get_math_mode(first_type);
|
||||
switch (math_type) {
|
||||
case MATH_FLOAT:
|
||||
|
||||
{
|
||||
auto result = env->make_xmm(first_type);
|
||||
env->emit(std::make_unique<IR_RegSet>(result, first_val->to_xmm(env)));
|
||||
env->emit(std::make_unique<IR_FloatMath>(FloatMathKind::DIV_SS, result, to_math_type(compile_error_guard(args.unnamed.at(1), env), math_type, env)->to_xmm(env))));
|
||||
}
|
||||
|
||||
case MATH_INVALID:
|
||||
throw_compile_error(
|
||||
form, "Cannot determine the math mode for object of type " + first_type.print());
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
assert(false);
|
||||
return get_none();
|
||||
}
|
Loading…
Reference in a new issue