Coder Social home page Coder Social logo

lir's Introduction

Lookup-only IR

Lookup-centric dsl is substitution of any kind of IR, asm

Simple structure for whole system

  • Programming Interface (Front-end)
    • Languge what developers use (It can be any programming language)
  • Intermediate (Middle-end)
    • Intermediate representation about lookup
    • It has logic gates, custom lookups
  • Prover (Back-end)
    • We can choose several system for backend (i.e. Baloo, cq, ...), of course it could be halo2
    • cq
      • Aggregation can be done theoretically
      • Single proof for single statement (or just function) and then aggregate (TBD)

Description

  1. Developer writes program
  2. Builder(inside system) constructs IR
  3. Virtual machine executes IR
  4. In the backend proving system, it recieves execution trace and lookup behavior.
  5. Backend proves it and returns proof

Flow

graph LR
FE(Programming Interface)
IR(Intermediate Representation)
VM(Virtual Machine)
FE --> IR
IR-->VM
VM-->|Program output|Output
IR-->|Lookup behavior|BE(Prover)
VM-->|Execution trace|BE
BE --> Proof
Loading

IR syntax

%result = lookup i4 %x, %y ADD

For binary operations

(operation result) = lookup (type) (from1) (from2) (Table)

There can be several instructions to be done by lookup. Each line is a combination of an operation and an assignment with single static assignment rule.

Table

For this intermediate layer, there should be two types of table.

  1. Fixed table

    • Instruction table
      • ADD, MUL, SUB, ...
      • All rows are made by all cases of operation
    • Program counter table
      • Not for all instructions
      • If pc meet jump, pc will be changed to dest
      • Store all jump behaviors
  2. Dynamic table

    • Imitate memory behavior
    • If some operation uses assigned value, lookup it
    • Is it able?

Structure

It will work as 8-bit architecture. If I can assure that table size for the other system that has more bits could work, it can be expanded.

Binary operation instruction

For one instruction, it does two dynamic lookup operations to get operand values from memory table. And also it does one lookup operation to its own operation result table which is a fixed table. And then put the result to the memory table. This IR will use single static assignment form (SSA), so the dynamic table's value wouldn't be changed. We should assume that the size of memory table is infinite, though it isn't.

Control flow & User-defined function

Phinode function will be used. User(circuit developer) can define any function, we can make new table for user-defined function. Program counter table will track jump instruction's destination.

Questions

Let's assume 2-bit system.

x y out
00 00 000
00 01 001
.. .. ..
11 11 110

For n-bit system, table size will be $2^{2n}$. If we make single bit logic gate and separate all instructions to bit operations, then the table size will be reduced but there will be more frequent lookup operations.

  • Should we make any limit for the values' size?
    • for the number of function?

TODO

  • Support argv for user input
  • Make jump table
  • Extend bit size by using bit operation

lir's People

Contributors

jeong0982 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.