-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#153 Refactor Intrinsics to make NaiveProgramGenerator more readable
- Loading branch information
1 parent
fbadf0d
commit be297c4
Showing
20 changed files
with
870 additions
and
518 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
core/src/main/java/de/mirkosertic/bytecoder/backend/js/JSIntrinsics.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,21 @@ | ||
/* | ||
* Copyright 2019 Mirko Sertic | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.mirkosertic.bytecoder.backend.js; | ||
|
||
import de.mirkosertic.bytecoder.intrinsics.Intrinsics; | ||
|
||
public class JSIntrinsics extends Intrinsics { | ||
} |
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
21 changes: 21 additions & 0 deletions
21
core/src/main/java/de/mirkosertic/bytecoder/backend/opencl/OpenCLIntrinsics.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,21 @@ | ||
/* | ||
* Copyright 2018 Mirko Sertic | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.mirkosertic.bytecoder.backend.opencl; | ||
|
||
import de.mirkosertic.bytecoder.intrinsics.Intrinsics; | ||
|
||
public class OpenCLIntrinsics extends Intrinsics { | ||
} |
21 changes: 21 additions & 0 deletions
21
core/src/main/java/de/mirkosertic/bytecoder/backend/wasm/WASMIntrinsics.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,21 @@ | ||
/* | ||
* Copyright 2017 Mirko Sertic | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.mirkosertic.bytecoder.backend.wasm; | ||
|
||
import de.mirkosertic.bytecoder.intrinsics.Intrinsics; | ||
|
||
public class WASMIntrinsics extends Intrinsics { | ||
} |
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
38 changes: 38 additions & 0 deletions
38
core/src/main/java/de/mirkosertic/bytecoder/intrinsics/Intrinsic.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,38 @@ | ||
/* | ||
* Copyright 2019 Mirko Sertic | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.mirkosertic.bytecoder.intrinsics; | ||
|
||
import de.mirkosertic.bytecoder.core.BytecodeInstructionINVOKESPECIAL; | ||
import de.mirkosertic.bytecoder.core.BytecodeInstructionINVOKESTATIC; | ||
import de.mirkosertic.bytecoder.core.BytecodeObjectTypeRef; | ||
import de.mirkosertic.bytecoder.ssa.*; | ||
|
||
import java.util.List; | ||
|
||
public class Intrinsic { | ||
|
||
public boolean intrinsify(final Program aProgram, final BytecodeInstructionINVOKESTATIC aInstruction, final String aMethodName, final List<Value> aArguments, | ||
final BytecodeObjectTypeRef aTargetClass, final RegionNode aTargetBlock, final ParsingHelper aHelper) { | ||
return false; | ||
} | ||
|
||
public boolean intrinsify(final Program aProgram, final BytecodeInstructionINVOKESPECIAL aInstruction, final String aMethodName, | ||
final BytecodeObjectTypeRef aType, final List<Value> aArguments, | ||
final Variable aTarget, final RegionNode aTargetBlock, final ParsingHelper aHelper) { | ||
return false; | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
core/src/main/java/de/mirkosertic/bytecoder/intrinsics/Intrinsics.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,68 @@ | ||
/* | ||
* Copyright 2019 Mirko Sertic | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.mirkosertic.bytecoder.intrinsics; | ||
|
||
import de.mirkosertic.bytecoder.core.BytecodeInstructionINVOKESPECIAL; | ||
import de.mirkosertic.bytecoder.core.BytecodeInstructionINVOKESTATIC; | ||
import de.mirkosertic.bytecoder.core.BytecodeObjectTypeRef; | ||
import de.mirkosertic.bytecoder.ssa.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Intrinsics { | ||
|
||
private final List<Intrinsic> intrinsics; | ||
|
||
public Intrinsics() { | ||
intrinsics = new ArrayList<>(); | ||
intrinsics.add(new MemoryManagerIntrinsic()); | ||
intrinsics.add(new JavaUtilArrayIntrinsic()); | ||
intrinsics.add(new VMIntrinsic()); | ||
intrinsics.add(new JavaLangStrictMathIntrinsic()); | ||
intrinsics.add(new JavaLangMathIntrinsic()); | ||
intrinsics.add(new RuntimeClassIntrinsic()); | ||
intrinsics.add(new ObjectConstructorCallIntrinsic()); | ||
} | ||
|
||
public void add(final Intrinsic aIntrinsic) { | ||
intrinsics.add(aIntrinsic); | ||
} | ||
|
||
public boolean intrinsify(final Program aProgram, final BytecodeInstructionINVOKESTATIC aInstruction, final List<Value> aArguments, | ||
final BytecodeObjectTypeRef aObjectType, final RegionNode aTargetBlock, final ParsingHelper aHelper) { | ||
final String theMethodName = aInstruction.getMethodReference().getNameAndTypeIndex().getNameAndType().getNameIndex().getName().stringValue(); | ||
for (final Intrinsic intrinsic : intrinsics) { | ||
if (intrinsic.intrinsify(aProgram, aInstruction, theMethodName, aArguments, aObjectType, aTargetBlock, aHelper)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public boolean intrinsify(final Program aProgram, final BytecodeInstructionINVOKESPECIAL aInstruction, | ||
final BytecodeObjectTypeRef aType, final List<Value> aArguments, | ||
final Variable aTarget, final RegionNode aTargetBlock, final ParsingHelper aHelper) { | ||
final String theMethodName = aInstruction.getMethodReference().getNameAndTypeIndex().getNameAndType().getNameIndex().getName().stringValue(); | ||
for (final Intrinsic intrinsic : intrinsics) { | ||
if (intrinsic.intrinsify(aProgram, aInstruction, theMethodName, aType, aArguments, aTarget, aTargetBlock, aHelper)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
Oops, something went wrong.