GithubHelp home page GithubHelp logo

Comments (4)

pgoodman avatar pgoodman commented on May 28, 2024

Some thoughts:

  • ZExt and SExt return value attributes. We should probably also find a way to put these attributes into FunctionDecls as well.
  • Investigate downstream uses of the value. Is it used in an arithmetic (signed) or logical shift (unsinged), in an unsigned or signed divide, in an add or sub with certain overflow characteristics, etc.

from anvill.

pgoodman avatar pgoodman commented on May 28, 2024

A function annotated to return a zext integer should produce a return value type of an unsigned integer, and a function annotated to return a sext integer should produce a return value type of a signed integer.

When parsing a function type or a function return value, if the integer type is un/signed, then we should add the corresponding zext or sext attributes.

from anvill.

artemdinaburg avatar artemdinaburg commented on May 28, 2024

Can someone explain why we need this? I thought the only thing that matters in LLVM-land is the comparisons, which are signed or unsigned, while all integers are always unsigned?

from anvill.

aaronyoo avatar aaronyoo commented on May 28, 2024

So I think when I first opened this issue I was trying to translate LLVM bitcode into a "spec". If I recall correctly this spec is basically a mapping of the llvm function signature to architecture specific set of memory locations and/or registers. When generating this spec it is useful to know whether or not an LLVM integer is signed or unsigned so we can keep that information in the spec.

The problem I was trying to tackle in this issue is to figure out from LLVM bitcode if an integer variable is signed or unsigned.

As @pgoodman suggested above, one simple way to do it is to inspect instructions involving that variable and see if we can deduce the signedness of it. Here is a very simple example where that approach would work: https://godbolt.org/z/j4YbjaTPq.

from anvill.

Related Issues (20)

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.