GitLab will be upgraded on June 2nd 2020 at 2.00 pm (AEDT) to 3.00 pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to local Gitlab admin team.

Commit 6ccfcd33 authored by Kunshan Wang's avatar Kunshan Wang

Updated parser.

parent 7a05f9e1
......@@ -117,9 +117,9 @@ instBody
| 'BRANCH' bbName # InstBranch
| 'BRANCH2' cond=value ifTrue=bbName ifFalse=bbName # InstBranch2
| 'SWITCH' '<' type '>' opnd=value defDest=bbName '{'
(caseVal=value ':' caseDest=bbName ';')* '}' # InstSwitch
(caseVal+=value ':' caseDest+=bbName ';')* '}' # InstSwitch
| 'PHI' '<' type '>' '{'
(caseSrc=bbName ':' caseVal=value ';')* '}' # InstPhi
(caseSrc+=bbName ':' caseVal+=value ';')* '}' # InstPhi
// Inter-function Control Flow
| 'CALL' funcCallBody excClause keepAliveClause # InstCall
......@@ -172,7 +172,7 @@ instBody
| 'SWAPSTACK' swappee=value curStackClause newStackClause excClause keepAliveClause # InstSwapStack
// Common Instructions
| 'COMMINST' typeList? argList? excClause keepAliveClause # InstCommInst
| 'COMMINST' nam=GLOBAL_NAME typeList? argList? excClause keepAliveClause # InstCommInst
;
bbName
......@@ -209,8 +209,8 @@ curStackClause
;
newStackClause
: 'PASS_PARAM' '<' type '>' value # NewStackPassParam
| 'NO_PARAM' # NewStackNoParam
: 'PASS_VALUE' '<' type '>' value # NewStackPassValue
| 'PASS_VOID' # NewStackPassVoid
| 'THROW_EXC' exc=value # NewStackThrowExc
;
......
......@@ -20,6 +20,7 @@ class Bundle {
val globalCellNs = new SimpleNamespace[GlobalCell]()
val funcNs = new SimpleNamespace[Function]()
val funcVerNs = new SimpleNamespace[FuncVer]()
private def simpleMerge[T <: Identified](oldNs: Namespace[T], newNs: Namespace[T]) {
for (cand <- newNs.all) {
......@@ -28,8 +29,8 @@ class Bundle {
} catch {
case e: NameConflictException =>
throw new IllegalRedefinitionException(
"Redefinition of type, function signature, declared constant," +
" global data or global value is not allowed", e);
"Redefinition of type, function signature, constant or" +
" global cell is not allowed", e);
}
}
}
......@@ -39,16 +40,18 @@ class Bundle {
val id = cand.id
oldNs.get(id) match {
case None => oldNs.add(cand)
case Some(oldObj) => oldObj.cfg = cand.cfg
case Some(oldObj) => oldObj.versions = cand.versions.head :: oldObj.versions
}
}
}
def merge(newBundle: Bundle) {
simpleMerge(varNs, newBundle.varNs)
simpleMerge(globalVarNs, newBundle.globalVarNs)
simpleMerge(typeNs, newBundle.typeNs)
simpleMerge(funcSigNs, newBundle.funcSigNs)
simpleMerge(declConstNs, newBundle.declConstNs)
simpleMerge(globalDataNs, newBundle.globalDataNs)
simpleMerge(globalValueNs, newBundle.globalValueNs)
simpleMerge(constantNs, newBundle.constantNs)
simpleMerge(globalCellNs, newBundle.globalCellNs)
simpleMerge(funcVerNs, newBundle.funcVerNs)
mergeFunc(funcNs, newBundle.funcNs)
}
}
......@@ -2,4 +2,6 @@ package uvm.ir.textinput
import uvm.UvmException
class TextIRParsingException(message: String = null, cause: Throwable = null) extends UvmException(message, cause)
\ No newline at end of file
class TextIRParsingException(message: String = null, cause: Throwable = null) extends UvmException(message, cause)
class UnexpectedTypeException(message: String = null, cause: Throwable = null) extends TextIRParsingException(message, cause)
\ No newline at end of file
......@@ -30,11 +30,9 @@ case class GlobalCell(var cellTy: Type) extends GlobalVariable
// Local variables: Parameters and Instructions
abstract class LocalVariable extends SSAVariable {
var funcVer: FuncVer = null
}
abstract class LocalVariable extends SSAVariable
case class Parameter(override var funcVer: FuncVer, var index: Int) extends LocalVariable
case class Parameter(var funcVer: FuncVer, var index: Int) extends LocalVariable
// Instructions
......@@ -109,14 +107,14 @@ trait HasExcClause extends Instruction {
}
trait HasKeepAliveClause extends Instruction {
var keepAlives: Seq[SSAVariable]
var keepAlives: Seq[LocalVariable]
}
abstract class AbstractCall extends CallLike
abstract class AbstractRet extends Instruction
abstract class AbstractAlloc extends Instruction {
abstract class AbstractAlloc extends HasExcClause {
def allocTy: Type
}
......@@ -139,8 +137,8 @@ case class RetWith(var retTy: Type) extends CurStackAction
case class KillOld() extends CurStackAction
abstract class NewStackAction
case class PassParam(var argTy: Type, var arg: SSAVariable) extends NewStackAction
case class NoParam() extends NewStackAction
case class PassValue(var argTy: Type, var arg: SSAVariable) extends NewStackAction
case class PassVoid() extends NewStackAction
case class ThrowExc(var exc: SSAVariable) extends NewStackAction
/// Concrete instructions
......@@ -164,7 +162,7 @@ case class InstSwitch(var opndTy: Type, var opnd: SSAVariable, var defDest: Basi
case class InstPhi(var opndTy: Type, var cases: Seq[(BasicBlock, SSAVariable)]) extends Instruction
case class InstCall(var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable],
var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable]
var excClause: Option[ExcClause], var keepAlives: Seq[LocalVariable]
) extends AbstractCall with HasExcClause with HasKeepAliveClause
case class InstTailCall(var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable]) extends AbstractCall
......@@ -177,41 +175,41 @@ case class InstThrow(var excVal: SSAVariable) extends Instruction
case class InstLandingPad() extends Instruction
case class InstExtractValue(var strTy: Type, var index: Int, var opnd: SSAVariable) extends Instruction
case class InstExtractValue(var strTy: TypeStruct, var index: Int, var opnd: SSAVariable) extends Instruction
case class InstInsertValue(var strTy: Type, var index: Int, var opnd: SSAVariable, var newVal: SSAVariable) extends Instruction
case class InstInsertValue(var strTy: TypeStruct, var index: Int, var opnd: SSAVariable, var newVal: SSAVariable) extends Instruction
case class InstExtractElement(var vecTy: Type, var indTy: TypeInt,
case class InstExtractElement(var vecTy: TypeVector, var indTy: TypeInt,
var opnd: SSAVariable, var index: SSAVariable) extends Instruction
case class InstInsertElement(var vecTy: Type, var indTy: TypeInt,
case class InstInsertElement(var vecTy: TypeVector, var indTy: TypeInt,
var opnd: SSAVariable, var index: SSAVariable, var newVal: SSAVariable) extends Instruction
case class InstShuffleVector(var vecTy: Type, var maskTy: Type,
case class InstShuffleVector(var vecTy: TypeVector, var maskTy: TypeVector,
var vec1: SSAVariable, var vec2: SSAVariable, var mask: SSAVariable) extends Instruction
case class InstNew(var allocTy: Type) extends HeapAlloc with FixedAlloc
case class InstNew(var allocTy: Type, var excClause: Option[ExcClause]) extends HeapAlloc with FixedAlloc
case class InstNewHybrid(var allocTy: Type, var length: SSAVariable) extends HeapAlloc with HybridAlloc
case class InstNewHybrid(var allocTy: TypeHybrid, var length: SSAVariable, var excClause: Option[ExcClause]) extends HeapAlloc with HybridAlloc
case class InstAlloca(var allocTy: Type) extends StackAlloc with FixedAlloc
case class InstAlloca(var allocTy: Type, var excClause: Option[ExcClause]) extends StackAlloc with FixedAlloc
case class InstAllocaHybrid(var allocTy: Type, var length: SSAVariable) extends StackAlloc with HybridAlloc
case class InstAllocaHybrid(var allocTy: TypeHybrid, var length: SSAVariable, var excClause: Option[ExcClause]) extends StackAlloc with HybridAlloc
case class InstGetIRef(var referentTy: Type, var opnd: SSAVariable) extends Instruction
case class InstGetFieldIRef(var referentTy: Type, var index: Int, var opnd: SSAVariable) extends Instruction
case class InstGetFieldIRef(var referentTy: TypeStruct, var index: Int, var opnd: SSAVariable) extends Instruction
case class InstGetElemIRef(var referentTy: Type, var indTy: TypeInt,
case class InstGetElemIRef(var referentTy: AbstractSeqType, var indTy: TypeInt,
var opnd: SSAVariable, var index: SSAVariable) extends Instruction
case class InstShiftIRef(var referentTy: Type, var offTy: TypeInt,
var opnd: SSAVariable, var offset: SSAVariable) extends Instruction
case class InstGetFixedPartIRef(var referentTy: Type, var opnd: SSAVariable) extends Instruction
case class InstGetFixedPartIRef(var referentTy: TypeHybrid, var opnd: SSAVariable) extends Instruction
case class InstGetVarPartIRef(var referentTy: Type, var opnd: SSAVariable) extends Instruction
case class InstGetVarPartIRef(var referentTy: TypeHybrid, var opnd: SSAVariable) extends Instruction
case class InstLoad(var ord: MemoryOrder, var referentTy: Type, var loc: SSAVariable) extends Instruction
......@@ -225,11 +223,11 @@ case class InstFence(var ord: MemoryOrder) extends Instruction
case class InstAtomicRMW(var ord: MemoryOrder, var op: AtomicRMWOptr,
var referentTy: Type, var loc: SSAVariable, var opnd: SSAVariable) extends Instruction
case class InstTrap(var retTy: Type, var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable]) extends AbstractTrap
case class InstTrap(var retTy: Type, var excClause: Option[ExcClause], var keepAlives: Seq[LocalVariable]) extends AbstractTrap
case class InstWatchPoint(var wpID: Int, var retTy: Type,
var dis: BasicBlock, var ena: BasicBlock, var exc: Option[BasicBlock],
var keepAlives: Seq[SSAVariable]) extends AbstractTrap
var keepAlives: Seq[LocalVariable]) extends AbstractTrap
case class InstCCall(var callConv: CallConv, var funcTy: Type,
var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable]) extends CallLike
......@@ -238,8 +236,8 @@ case class InstNewStack(var sig: FuncSig, var callee: SSAVariable, var argList:
var excClause: Option[ExcClause]) extends CallLike with HasExcClause
case class InstSwapStack(var swappee: SSAVariable, var curStackAction: CurStackAction, var newStackAction: NewStackAction,
var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable]) extends HasExcClause with HasKeepAliveClause
var excClause: Option[ExcClause], var keepAlives: Seq[LocalVariable]) extends HasExcClause with HasKeepAliveClause
case class InstCommInst(var inst: CommInst, var typeList: Seq[Type], var argList: Seq[SSAVariable],
var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable])
var excClause: Option[ExcClause], var keepAlives: Seq[LocalVariable])
extends HasTypeList with HasArgList with HasExcClause with HasKeepAliveClause
......@@ -12,6 +12,11 @@ abstract class AbstractRefType extends Type {
def ty: Type
}
abstract class AbstractSeqType extends Type {
def elemTy: Type
def len: Long
}
case class TypeInt(var length: Int) extends Type
case class TypeFloat() extends FPType
case class TypeDouble() extends FPType
......@@ -19,14 +24,14 @@ case class TypeRef(var ty: Type) extends AbstractRefType
case class TypeIRef(var ty: Type) extends AbstractRefType
case class TypeWeakRef(var ty: Type) extends AbstractRefType
case class TypeStruct(var fieldTy: Seq[Type]) extends Type
case class TypeArray(var elemTy: Type, var len: Long) extends Type
case class TypeArray(var elemTy: Type, var len: Long) extends AbstractSeqType
case class TypeHybrid(var fixedTy: Type, var varTy: Type) extends Type
case class TypeVoid() extends Type
case class TypeFunc(var sig: FuncSig) extends Type
case class TypeThread() extends Type
case class TypeStack() extends Type
case class TypeTagRef64() extends Type
case class TypeVector(var elemTy: Type, var len: Long) extends Type
case class TypeVector(var elemTy: Type, var len: Long) extends AbstractSeqType
object Type {
def prettyPrint(ty: Type): String = ty match {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment