Giter Site home page Giter Site logo

cgen's People

Contributors

alexfikl avatar angus-g avatar blgene avatar bryancatanzaro avatar dependabot[bot] avatar dokempf avatar graham13 avatar inducer avatar isuruf avatar kaushikcfd avatar lcw avatar mattwala avatar navjotk avatar sauci avatar vinayvasista avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cgen's Issues

split preprocessor-related classes to different file

with the current file structure, it is not possible to implement the preprocessor #if statement, as it would overwrite (or be overwritten by) the C if () statement.

I would propose to update the file structure to:

cgen
+-- cgen
    +-- __init__.py
    +-- cuda.py
    +-- ispc.py
    +-- mapper.py
    +-- opencl.py
    +-- preprocessor
        +-- __init__.py

and implement the preprocessor #if (and others preprocessor statements?) in the file cgen/preprocessor/__init__.py.
this would provide access to the preprocessor functionalities like this:

import cgen as c
import cgen.preprocessor as pp
func = c.FunctionBody(
    c.FunctionDeclaration(c.Const(c.Pointer(c.Value("char", "greet"))), []),
    c.Block([
        pp.If('(a == 0)',
            [
                c.If('b == 0', c.Block([
                    c.Statement('return "hello world"')
                ]))
            ],
            [])
        ])
    )

print(func)

and will output something like:

char const *greet()
{
  #if (a == 0)
  if (b == 0)
  {
    return "hello world";
  }
  #endif
}

Classes for IfDef and InlineInitializers

While trying to modify opesci-fd to use this project's code generation capabilities, there were some classes I would have found helpful but couldn't find them in cgen. I added them to a wrapper and used them in the project. These include a class for IfDef and one for InlineInitializers. If you think they would be helpful to this project, I could submit a pull request here.

if, else-if, else structure

Hello, guys,

Is it possible to generate if-else-if structure using cgen?

if (condition_1) declaration_1;
else if (condition_2) declaration_2;
else if (condition_3) declaration_3;
.
.
.
else if (condition_n) declaration_n;
else declaration_default;

Wrong result for nested type

Both

Pointer(ArrayOf(Pointer(POD(np.float32, "xxx")), 2)),
Pointer(Pointer(ArrayOf(POD(np.float32, "yyy"), 2))),

result in

float **xxx[2];
float **yyy[2];

The expected result is

float *(*xxx)[2];
float (**xxx)[2];

How to merge initialisation and assignment in cgen?

I have a cgen.Value("float", "temp") and an assignemnt, cgen.Assign("temp", "somefunc(1)"). It will generate the following C code

float temp;
temp = somefunc(1);

How to make the generated C code more nested from cgen.Value and cgen.Assign, such that it will look like:

float temp = somefunc(1);

Arithmetic expression

I would like to generate arithmetic expressions. for example:

float z = -25.f
float x = -(1.5f * 3e5) + (z / 123.f);

What is the idiomatic way to do it with cgen?

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.