~maelkum/viuavm

113f107ac2d2df1c13b6071a903f15c20d3a4329 — Marek Marecki 1 year, 3 months ago 60592a6
Rename allocation pseudoinstructions from A* to AM*

The instruction for dynamically allocating a double-world was named ADD
in the old scheme, which conflicted with arithmetic ADD instruction. The
new scheme uses a better prefix: AM - Allocate Memory.
M new/include/viua/libs/lexer.h => new/include/viua/libs/lexer.h +14 -14
@@ 268,10 268,10 @@ inline auto const OPCODE_NAMES = std::set<std::string>{
    "g.sm",
    "lm",
    "g.lm",
    "aa",
    "g.aa",
    "ad",
    "g.ad",
    "ama",
    "g.ama",
    "amd",
    "g.amd",
    "ptr",
    "g.ptr",



@@ 301,16 301,16 @@ inline auto const OPCODE_NAMES = std::set<std::string>{
    "lq",
    "mq",

    "aba",
    "aha",
    "awa",
    "ada",
    "aqa",
    "abd",
    "ahd",
    "awd",
    "add",
    "aqd",
    "amba",
    "amha",
    "amwa",
    "amda",
    "amqa",
    "ambd",
    "amhd",
    "amwd",
    "amdd",
    "amqd",
};

auto lex(std::string_view) -> std::vector<Lexeme>;

M new/src/arch/ops.cpp => new/src/arch/ops.cpp +4 -4
@@ 431,9 431,9 @@ auto to_string(opcode_type const raw) -> std::string
    case OPCODE::LM:
        return greedy + "lm";
    case OPCODE::AA:
        return greedy + "aa";
        return greedy + "ama";
    case OPCODE::AD:
        return greedy + "ad";
        return greedy + "amd";
    case OPCODE::PTR:
        return greedy + "ptr";
    }


@@ 582,9 582,9 @@ auto parse_opcode(std::string_view const raw) -> opcode_type
        return (op | static_cast<opcode_type>(OPCODE::SM));
    } else if (sv == "lm") {
        return (op | static_cast<opcode_type>(OPCODE::LM));
    } else if (sv == "aa") {
    } else if (sv == "ama") {
        return (op | static_cast<opcode_type>(OPCODE::AA));
    } else if (sv == "ad") {
    } else if (sv == "amd") {
        return (op | static_cast<opcode_type>(OPCODE::AD));
    } else if (sv == "ptr") {
        return (op | static_cast<opcode_type>(OPCODE::PTR));

M new/src/tools/exec/dis.cpp => new/src/tools/exec/dis.cpp +1 -1
@@ 430,7 430,7 @@ auto demangle_memory(Cooked_text& text) -> void
                    break;
                case AA:
                case AD:
                    name = "a";
                    name = "am";
                    break;
                default:
                    abort();

M new/src/tools/libs/stage.cpp => new/src/tools/libs/stage.cpp +16 -13
@@ 994,10 994,10 @@ auto expand_memory_access(std::vector<ast::Instruction>& cooked,
    if (synth.opcode.text[0] == 'a') {
        switch (synth.opcode.text.back()) {
            case 'a':
                synth.opcode.text = "aa";
                synth.opcode.text = "ama";
                break;
            case 'd':
                synth.opcode.text = "ad";
                synth.opcode.text = "amd";
                break;
            default:
                abort();


@@ 1010,7 1010,10 @@ auto expand_memory_access(std::vector<ast::Instruction>& cooked,
    synth.operands.push_back(raw.operands.at(1));
    synth.operands.push_back(raw.operands.at(2));

    switch (raw.opcode.text[1]) {
    auto const unit = raw.opcode.text[0] == 'a'
        ? raw.opcode.text[2]
        : raw.opcode.text[1];
    switch (unit) {
        case 'b':
            synth.operands.front().ingredients.front().text = "0";
            break;


@@ 1061,16 1064,16 @@ auto expand_pseudoinstructions(std::vector<ast::Instruction> raw,
        "sq",
        "lq",
        "mq",
        "aba",
        "aha",
        "awa",
        "ada",
        "aqa",
        "abd",
        "ahd",
        "awd",
        "add",
        "aqd",
        "amba",
        "amha",
        "amwa",
        "amda",
        "amqa",
        "ambd",
        "amhd",
        "amwd",
        "amdd",
        "amqd",
    };

    /*