Giter VIP home page Giter VIP logo

iop's Introduction

Mostly complete parser/gramamr for Intel's intrinsics pseudocode. There are still some edge cases to work out (minor errors and inconsistencies in the pseudocode).

After cloning this repo, use yarn get-data to fetch Intel's intrinsic guide.

Example of vplzcntd:

FOR j := 0 to 7
	i := j*32
	tmp := 31
	dst[i+31:i] := 0
	DO WHILE (tmp >= 0 AND a[i+tmp] == 0)
		tmp := tmp - 1
		dst[i+31:i] := dst[i+31:i] + 1
	OD
ENDFOR
dst[MAX:256] := 0
{
  type: 'Program',
  body: [
    {
      type: 'ForStatement',
      init: [
        {
          type: 'AssignmentExpression',
          operator: ':=',
          left: { type: 'Identifier', name: 'j' },
          right: { type: 'Literal', value: 0 }
        },
        [ ' ' ]
      ],
      varmax: { type: 'Literal', value: 7 },
      body: [
        [
          {
            type: 'ExpressionStatement',
            expression: {
              type: 'AssignmentExpression',
              operator: ':=',
              left: { type: 'Identifier', name: 'i' },
              right: {
                type: 'BinaryExpression',
                operator: '*',
                left: { type: 'Identifier', name: 'j' },
                right: { type: 'Literal', value: 32 }
              }
            }
          },
          {
            type: 'ExpressionStatement',
            expression: {
              type: 'AssignmentExpression',
              operator: ':=',
              left: { type: 'Identifier', name: 'tmp' },
              right: { type: 'Literal', value: 31 }
            }
          },
          {
            type: 'ExpressionStatement',
            expression: {
              type: 'AssignmentExpression',
              operator: ':=',
              left: {
                type: 'MemberExpression',
                object: { type: 'Identifier', name: 'dst' },
                range: {
                  start: {
                    type: 'BinaryExpression',
                    operator: '+',
                    left: { type: 'Identifier', name: 'i' },
                    right: { type: 'Literal', value: 31 }
                  },
                  end: { type: 'Identifier', name: 'i' }
                },
                computed: true
              },
              right: { type: 'Literal', value: 0 }
            }
          },
          {
            type: 'DoWhileStatement',
            test: {
              type: 'BinaryExpression',
              operator: [ 'AND', undefined ],
              left: {
                type: 'BinaryExpression',
                operator: '>=',
                left: { type: 'Identifier', name: 'tmp' },
                right: { type: 'Literal', value: 0 }
              },
              right: {
                type: 'BinaryExpression',
                operator: '==',
                left: {
                  type: 'MemberExpression',
                  object: { type: 'Identifier', name: 'a' },
                  property: {
                    type: 'BinaryExpression',
                    operator: '+',
                    left: { type: 'Identifier', name: 'i' },
                    right: { type: 'Identifier', name: 'tmp' }
                  },
                  computed: true
                },
                right: { type: 'Literal', value: 0 }
              }
            },
            body: [
              [
                {
                  type: 'ExpressionStatement',
                  expression: {
                    type: 'AssignmentExpression',
                    operator: ':=',
                    left: { type: 'Identifier', name: 'tmp' },
                    right: {
                      type: 'BinaryExpression',
                      operator: '-',
                      left: { type: 'Identifier', name: 'tmp' },
                      right: { type: 'Literal', value: 1 }
                    }
                  }
                },
                {
                  type: 'ExpressionStatement',
                  expression: {
                    type: 'AssignmentExpression',
                    operator: ':=',
                    left: {
                      type: 'MemberExpression',
                      object: { type: 'Identifier', name: 'dst' },
                      range: {
                        start: {
                          type: 'BinaryExpression',
                          operator: '+',
                          left: { type: 'Identifier', name: 'i' },
                          right: { type: 'Literal', value: 31 }
                        },
                        end: { type: 'Identifier', name: 'i' }
                      },
                      computed: true
                    },
                    right: {
                      type: 'BinaryExpression',
                      operator: '+',
                      left: {
                        type: 'MemberExpression',
                        object: { type: 'Identifier', name: 'dst' },
                        range: {
                          start: {
                            type: 'BinaryExpression',
                            operator: '+',
                            left: { type: 'Identifier', name: 'i' },
                            right: { type: 'Literal', value: 31 }
                          },
                          end: { type: 'Identifier', name: 'i' }
                        },
                        computed: true
                      },
                      right: { type: 'Literal', value: 1 }
                    }
                  }
                }
              ],
              [ '\t' ]
            ]
          }
        ],
        []
      ]
    },
    {
      type: 'ExpressionStatement',
      expression: {
        type: 'AssignmentExpression',
        operator: ':=',
        left: {
          type: 'MemberExpression',
          object: { type: 'Identifier', name: 'dst' },
          range: {
            start: { type: 'Identifier', name: 'MAX' },
            end: { type: 'Literal', value: 256 }
          },
          computed: true
        },
        right: { type: 'Literal', value: 0 }
      }
    }
  ]
}

Notes:

  1. Some incorrect characters appear in the Intel documents. The following replacements should be made:
    x2013: "-" // en dash
    x2044: "/"

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.