Skip to content

Commit

Permalink
Merge pull request #123 from ftsrg/fp
Browse files Browse the repository at this point in the history
Adding Support for Floating Point Arithmetic
  • Loading branch information
leventeBajczi authored Aug 4, 2021
2 parents d12a0c4 + 9733f6f commit fe8f9c8
Show file tree
Hide file tree
Showing 51 changed files with 4,236 additions and 186 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {

allprojects {
group = "hu.bme.mit.inf.theta"
version = "2.17.0"
version = "2.18.0"

apply(from = rootDir.resolve("gradle/shared-with-buildSrc/mirrors.gradle.kts"))
}
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {

repositories {
gradlePluginPortal()
mavenCentral()
}

apply(from = rootDir.resolve("../gradle/shared-with-buildSrc/mirrors.gradle.kts"))
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/java-common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ apply(plugin = "jacoco-common")
dependencies {
val implementation: Configuration by configurations
val testImplementation: Configuration by configurations
val libPath: String by rootProject.extra

implementation(Deps.guava)
implementation(fileTree(mapOf("dir" to libPath, "include" to listOf("*.jar"))))
implementation("org.fusesource.hawtjni:hawtjni-runtime:1.18")
testImplementation(Deps.junit4)
testImplementation(Deps.Mockito.core)
}
Expand Down
45 changes: 45 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,49 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

GNU MPFR is licensed under the following license:
```
Copyright 1991, 1993-2020 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in GNU Free Documentation License.
The GNU MPFR Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
The GNU MPFR Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
```

MPFR-JAVA is licensed under the following license:
```
==============================================================================
The K Release License
==============================================================================
University of Illinois/NCSA
Open Source License
Copyright (c) 2014 University of Illinois at Urbana-Champaign.
All rights reserved.
Developed by:
K Team
University of Illinois at Urbana-Champaign
University Alexandru-Ioan Cuza, Romania
Runtime Verification, Inc.
http://kframework.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution.
* Neither the names of the K Team, the University of Illinois at Urbana-Champaign, the University Alexandru-Ioan Cuza, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
```
Binary file added lib/libmpfr_java-1.0.so
Binary file not shown.
Binary file added lib/mpfr_java-1.0-linux64.jar
Binary file not shown.
Binary file added lib/mpfr_java-1.0.jar
Binary file not shown.
107 changes: 103 additions & 4 deletions subprojects/cfa/cfa/src/main/antlr/CfaDsl.g4
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type: boolType
| funcType
| arrayType
| bvType
| fpType
;

typeList
Expand Down Expand Up @@ -111,6 +112,10 @@ bvType
: BVTYPE LBRACK size=INT RBRACK
;

fpType
: FPTYPE FP_TYPE_DECL
;

BOOLTYPE
: 'bool'
;
Expand All @@ -127,6 +132,10 @@ BVTYPE
: 'bv'
;

FPTYPE
: 'fp'
;

// E X P R E S S I O N S

expr: funcLitExpr
Expand Down Expand Up @@ -155,7 +164,7 @@ implyExpr
;

quantifiedExpr
: orExpr
: fpFuncExpr
| forallExpr
| existsExpr
;
Expand All @@ -168,6 +177,10 @@ existsExpr
: EXISTS LPAREN paramDecls=declList RPAREN op=quantifiedExpr
;

fpFuncExpr
: leftOp=orExpr (oper=(FPMAX | FPMIN) rightOp=orExpr)?
;

orExpr
: ops+=xorExpr (OR ops+=xorExpr)*
;
Expand Down Expand Up @@ -210,11 +223,11 @@ bitwiseShiftExpr
;

additiveExpr
: ops+=multiplicativeExpr (opers+=(PLUS | MINUS | BV_ADD | BV_SUB) ops+=multiplicativeExpr)*
: ops+=multiplicativeExpr (opers+=(PLUS | MINUS | BV_ADD | BV_SUB | FPADD | FPSUB) ops+=multiplicativeExpr)*
;

multiplicativeExpr
: ops+=bvConcatExpr (opers+=(MUL | DIV | MOD | REM | BV_MUL | BV_UDIV | BV_SDIV | BV_SMOD | BV_UREM | BV_SREM) ops+=bvConcatExpr)*
: ops+=bvConcatExpr (opers+=(MUL | DIV | MOD | REM | BV_MUL | BV_UDIV | BV_SDIV | BV_SMOD | BV_UREM | BV_SREM | FPREM | FPMUL | FPDIV) ops+=bvConcatExpr)*
;

bvConcatExpr
Expand All @@ -227,7 +240,7 @@ bvExtendExpr

unaryExpr
: bitwiseNotExpr
| oper=(PLUS | MINUS | BV_POS | BV_NEG) op=unaryExpr
| oper=(PLUS | MINUS | BV_POS | BV_NEG | FP_ABS | FP_IS_NAN | FPROUNDTOINT | FPSQRT | FPTOFP | FPTOBV | FP_FROM_BV | FPNEG | FPPOS ) op=unaryExpr
;

bitwiseNotExpr
Expand Down Expand Up @@ -273,6 +286,7 @@ primaryExpr
| intLitExpr
| ratLitExpr
| arrLitExpr
| fpLitExpr
| bvLitExpr
| idExpr
| parenExpr
Expand Down Expand Up @@ -303,6 +317,10 @@ bvLitExpr
: bv=BV
;

fpLitExpr
: sig=(PLUS | MINUS)? bvLitExpr DOT bvLitExpr
;

idExpr
: id=ID
;
Expand Down Expand Up @@ -510,9 +528,89 @@ BV_SGE
: 'bvsge'
;

FP_ABS
: 'fpabs'
;

FP_FROM_BV
: 'fpfrombv' FP_TYPE_DECL (LBRACK SIGNEDNESS RBRACK) FP_ROUNDINGMODE?
;

FP_IS_NAN
: 'fpisnan'
;

FPMAX
: 'fpmax' FP_ROUNDINGMODE?
;

FPMIN
: 'fpmin' FP_ROUNDINGMODE?
;

FPREM
: 'fprem' FP_ROUNDINGMODE?
;

FPROUNDTOINT
: 'fproundtoint' FP_ROUNDINGMODE?
;

FPSQRT
: 'fpsqrt' FP_ROUNDINGMODE?
;

FPTOBV
: 'fptobv' BV_TYPE_DECL FP_ROUNDINGMODE?
;

FPTOFP
: 'fptofp' FP_TYPE_DECL FP_ROUNDINGMODE?
;

FPSUB
: 'fpsub' FP_ROUNDINGMODE?
;

FPADD
: 'fpadd' FP_ROUNDINGMODE?
;

FPMUL
: 'fpmul' FP_ROUNDINGMODE?
;

FPDIV
: 'fpdiv' FP_ROUNDINGMODE?
;

FPPOS
: 'fppos' FP_ROUNDINGMODE?
;

FPNEG
: 'fpneg' FP_ROUNDINGMODE?
;

TRUE: 'true'
;

BV_TYPE_DECL
: LBRACK NAT '\'' SIGNEDNESS RBRACK
;

SIGNEDNESS
: ('u' | 's')
;

FP_TYPE_DECL
: LBRACK NAT COLON NAT RBRACK
;

FP_ROUNDINGMODE
: LBRACK [A-Z]* RBRACK
;

FALSE
: 'false'
;
Expand Down Expand Up @@ -660,3 +758,4 @@ COMMENT
LINE_COMMENT
: '//' ~[\r\n]* -> skip
;

Loading

0 comments on commit fe8f9c8

Please sign in to comment.