自制编译器 青木峰郎 笔记 Ch11 IR转换

11.1 IR

Cb使用的是树形IR。

cbc --dump-ir if_test.cb
<<IR>> (if_test.cb:1)
variables:
functions:
    <<DefinedFunction>> (if_test.cb:2)
    name: main
    isPrivate: false
    type: int(int, char**)
    body:
        <<CJump>> (if_test.cb:4)
        cond:
            <<Int>>
            type: INT32
            value: 1
        thenLabel: 123a439b
        elseLabel: 7de26db8
        <<LabelStmt>> (null)
        label: 123a439b
        <<CJump>> (if_test.cb:4)
        cond:
            <<Int>>
            type: INT32
            value: 2
        thenLabel: 1175e2db
        elseLabel: 36aa7bc2
        <<LabelStmt>> (null)
        label: 1175e2db
        <<ExprStmt>> (if_test.cb:4)
        expr:
            <<Call>>
            type: INT32
            expr:
                <<Addr>>
                type: INT32
                entity: puts
            args:
                <<Str>>
                type: INT32
                entry: net.loveruby.cflat.entity.ConstantEntry@76ccd017
        <<Jump>> (null)
        label: 182decdb
        <<LabelStmt>> (null)
        label: 36aa7bc2
        <<CJump>> (if_test.cb:5)
        cond:
            <<Int>>
            type: INT32
            value: 3
        thenLabel: 26f0a63f
        elseLabel: 4361bd48
        <<LabelStmt>> (null)
        label: 26f0a63f
        <<ExprStmt>> (if_test.cb:5)
        expr:
            <<Call>>
            type: INT32
            expr:
                <<Addr>>
                type: INT32
                entity: puts
            args:
                <<Str>>
                type: INT32
                entry: net.loveruby.cflat.entity.ConstantEntry@53bd815b
        <<Jump>> (null)
        label: 2401f4c3
        <<LabelStmt>> (null)
        label: 4361bd48
        <<ExprStmt>> (if_test.cb:6)
        expr:
            <<Call>>
            type: INT32
            expr:
                <<Addr>>
                type: INT32
                entity: puts
            args:
                <<Str>>
                type: INT32
                entry: net.loveruby.cflat.entity.ConstantEntry@7637f22
        <<LabelStmt>> (null)
        label: 2401f4c3
        <<LabelStmt>> (null)
        label: 182decdb
        <<LabelStmt>> (null)
        label: 7de26db8
        <<Return>> (if_test.cb:7)
        expr:
            <<Int>>
            type: INT32
            value: 0

上一篇:Redis命令


下一篇:linux fg bg ctrl + z jobs & 等命令