Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: add hooks for floating point comparisons #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pablooliveira
Copy link
Member

@pablooliveira pablooliveira commented Aug 8, 2019

Verificarlo is preparing to move fully towards the interflop interface (verificarlo/verificarlo#93).

In this context we would like to instrument floating point comparisons (fcmp).

This is a proposal to add two hooks to interflop.h with the following conventions,

/* interflop float compare predicates, follows the same order than
 * LLVM's FCMPInstruction predicates */
enum FCMP_PREDICATE {
  FCMP_FALSE,
  FCMP_OEQ,
  FCMP_OGT,
  FCMP_OGE,
  FCMP_OLT,
  FCMP_OLE,
  FCMP_ONE,
  FCMP_ORD,
  FCMP_UNO,
  FCMP_UEQ,
  FCMP_UGT,
  FCMP_UGE,
  FCMP_ULT,
  FCMP_ULE,
  FCMP_UNE,
  FCMP_TRUE,
};

struct interflop_backend_interface_t {
  // [...]
  void (*interflop_cmp_float)(enum FCMP_PREDICATE p, float a, float b, int *c,
                              void *context);
  // [...]
  void (*interflop_cmp_double)(enum FCMP_PREDICATE p, double a, double b, int *c,
                               void *context);
};

The enumeration FCMP_PREDICATE contains the 16 floating point operators supported by LLVM. We think it is better to have only two hooks predicated with the enum, instead of 32 individual hooks (16 for float and 16 for double).

Since we are mainly using the LLVM frontend, this is very practical for us. But we are flexible if another representation is more general or practical.

In this PR, I have only modified interflop.h to start the discussion. If this proposal is accepted, we should update the existing backends and the C++ interface before merging.

@pablooliveira
Copy link
Member Author

@Helios77760 please feel free to comment on this !

@pablooliveira pablooliveira changed the title Proposal: Add hooks for floating point comparisons Proposal: add hooks for floating point comparisons Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant