Cuik icon indicating copy to clipboard operation
Cuik copied to clipboard

Tilde Requests

Open gingerBill opened this issue 2 years ago • 4 comments

I will add to this as I go along when I see things which may be missing.

API

  • [x] Any function that takes a const char* also take a length where possible
    • Maybe using your convention of when ptrdiff_t is -1, it's NUL terminated
  • [x] Function Signature ABI handling
    • Documentation
    • Better Abstraction that handles it for you, maybe?
  • [ ] f16 type
    • Even if it is just u16 internally or whatever
  • [x] Range bounds on values to improve generation of bounds checks
    • If a pointer-like array has a specific range to it, and an integer is know to have a specific range, then a bounds check may be omitted
  • [x] Minimum alignment of a TB_Node* (useful in some instructions that require an explicit alignment)

Instructions

  • [ ] alloca equivalent
  • [x] tb_inst_ptr is missing
  • [ ] tb_inst_sint/tb_inst_uint for types >64 bits (e.g. 128-bits)
  • [ ] tb_inst_memmove
    • High Priority
  • [ ] TB_(SHL|SHR|SAR) with slightly different to C semantics
    • Instead of C-like, I want Odin-like which is defined to have x<<2 == (x<<1)<<1
  • [ ] TB_BSWAP work with floats
    • useful for endian specific types and file formats
  • [ ] add/sub/mul with overflow check
    • Low priority, and for mul it can be done with TB_MULPAIR
  • [ ] add/sub/mul with saturation
    • Extension to TB_ArithmeticBehavior maybe?
    • Very low priority
  • [ ] fused multiply add (fma)
    • Very low priority
  • [ ] nontemporal stores and loads
    • Low priority
  • [ ] Fixed point arithmetic? (I'm not sure about this one)
    • Very low priority
  • [x] Prefetch (read/write data/instruction)
    • Very low priority
  • [ ] WASM intrinsics (when WASM is needed)
    • wasm.memory.grow
    • wasm.memory.size
    • wasm.memory.atomic.wait32
    • wasm.memory.atomic.notify
  • [x] tb_inst_memzero helper?
    • Is this even a needed?
TB_API void tb_inst_memzero(TB_Function* f, TB_Node* dst, TB_Node* val, TB_Node* count, TB_CharUnits align, bool is_volatile) {
    tb_inst_memset(f, dst, tb_inst_uint(f, TB_TYPE_I8, 0), count, align, is_volatile);
}

"Intrinsics"

  • [ ] cpu_relax
    • pause on amd64
    • isb on arm64
  • [ ] x86_cpuid
  • [ ] x86_xgetbv
  • [ ] Valgrind client request
    • It's just a weird set of instructions that does nothing but Valgrind et al looks for

IR Debugging

  • [x] Linearized Textual IR Printer (not GraphViz)

Debug Information

  • [x] Set column information along with file and line information
  • [ ] Ability to set scopes
  • [ ] Enum Types
  • [x] Named types

Questions

  • Does tb_inst_set_region_name require that the name passed is in unique to that function or does Tilde handle this?
  • How to get the previous instruction?—i.e. of a region

gingerBill avatar Jul 14 '23 13:07 gingerBill

For the questions, currently tb_inst_set_region_name does not require unique names but it will bite you once i make the flattened IR form if you reuse the same name.

If you wanna know the previous "instructions" to a region, you can check the inputs list and it'll tell you all the predecessors, you can do tb_get_parent_region(region->inputs[i]) if you want the top of that predecessor, but the actual inputs[i] is almost always a projection (TB_PROJ) stemming from a branch, you can reach the branch with another ->inputs[0].

RealNeGate avatar Jul 14 '23 19:07 RealNeGate

image

There we go, linearized IR printing. It uses the TB_FuncOpt which is usually is preserved for optimizations but i might rename it because it's really just for analysis/transformations and flattening the IR is a form of analysis.

RealNeGate avatar Jul 15 '23 02:07 RealNeGate

Feature Request:

  • Debug type for functions
  • From debug type, it can produce the function prototype type for the specified ABI.

gingerBill avatar Jul 15 '23 19:07 gingerBill

@gingerBill @RealNeGate I have a crazy off-topic idea/question for you guys. Odin is "done". So why not write a C compiler(or at least compiler backend) in Odin?

I imagine Odin will provide great productivity gains and correctness as well.

(I am currently playing with Odin and I love it, and I heard that GB wants to replace LLVM with Tilde)

ngortheone avatar Oct 10 '24 15:10 ngortheone