-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide (faked) support for 96-bit floating point values.
Just use 64-bit doubles. Unfortunately, I can't find a way to configure GCC 4.7 to use a smaller size for the "long double" type, so we have to play some games with pointers.
- Loading branch information
Showing
16 changed files
with
482 additions
and
70 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
tools/gcc-bridge/compiler/src/main/java/org/renjin/gcc/codegen/expr/BinaryOpExpr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Renjin : JVM-based interpreter for the R language for the statistical analysis | ||
* Copyright © 2010-2016 BeDataDriven Groep B.V. and contributors | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, a copy is available at | ||
* https://www.gnu.org/licenses/gpl-2.0.txt | ||
*/ | ||
package org.renjin.gcc.codegen.expr; | ||
|
||
import org.renjin.gcc.codegen.MethodGenerator; | ||
import org.renjin.repackaged.asm.Type; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class BinaryOpExpr implements JExpr { | ||
|
||
private int opcode; | ||
private Type resultType; | ||
private JExpr x; | ||
private JExpr y; | ||
|
||
|
||
public BinaryOpExpr(int opcode, JExpr x, JExpr y) { | ||
this.opcode = opcode; | ||
this.resultType = x.getType(); | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public BinaryOpExpr(int opcode, Type resultType, JExpr x, JExpr y) { | ||
this.opcode = opcode; | ||
this.resultType = resultType; | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public int getOpcode() { | ||
return opcode; | ||
} | ||
|
||
public JExpr getX() { | ||
return x; | ||
} | ||
|
||
public JExpr getY() { | ||
return y; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Type getType() { | ||
return resultType; | ||
} | ||
|
||
@Override | ||
public void load(@Nonnull MethodGenerator mv) { | ||
x.load(mv); | ||
y.load(mv); | ||
mv.visitInsn(x.getType().getOpcode(opcode)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tools/gcc-bridge/compiler/src/test/resources/org/renjin/gcc/real96.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "assert.h" | ||
|
||
|
||
void test_real96() { | ||
|
||
long double x = 1/3; | ||
long double y = 2/3; | ||
|
||
ASSERT( fabs((2.0*x) - y) < 0.00001); | ||
} | ||
|
||
void test_real96_pointers() { | ||
|
||
long double a[6]; | ||
a[0] = 100; | ||
a[1] = 101; | ||
a[2] = 102; | ||
a[3] = 103; | ||
a[4] = 104; | ||
a[5] = 105; | ||
|
||
long double *pa = &a[0]; | ||
long double *pb = &a[3]; | ||
|
||
ASSERT(*pa == 100); | ||
ASSERT(*pb == 103); | ||
ASSERT(pb[2] == 105); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.