public void SimpleAshr_ParseCheck() { LAshr ashr = new LAshr(_valueResult, _valueOp1, _valueOp2); Assert.AreEqual($"{_valueResult.Identifier} = ashr {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {_valueOp2.ValueOrIdentifier}", LHelper.Trim(ashr.ParseInstruction())); }
public void Ret_ParseCheck_i32_Value_Ok() { LValueRef valueRef = new LValueRef(LType.Int32Type(), "12"); LRet ret = new LRet(valueRef); Assert.AreEqual($"{LKeywords.Ret} i32 12", LHelper.Trim(ret.ParseInstruction())); }
public void SimpleLshr_ParseCheck() { LShl shl = new LShl(_valueResult, _valueOp1, _valueOp2); Assert.AreEqual($"{_valueResult.Identifier} = shl {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {_valueOp2.ValueOrIdentifier}", LHelper.Trim(shl.ParseInstruction())); }
public void SimpleXor_ParseCheck() { LXor xor = new LXor(_valueResult, _valueOp1, _valueOp2); Assert.AreEqual($"{_valueResult.Identifier} = xor {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {_valueOp2.ValueOrIdentifier}", LHelper.Trim(xor.ParseInstruction())); }
public void SimpleAllocaParse_Expected_True() { LAlloca alloca = new LAlloca(_function, LType.Int32Type()); Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}", LHelper.Trim(alloca.ParseInstruction())); }
public void SimpleAnd_ParseCheck() { LAnd and = new LAnd(_valueResult, _valueOp1, _valueOp2); Assert.AreEqual($"{_valueResult.Identifier} = and {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {_valueOp2.ValueOrIdentifier}", LHelper.Trim(and.ParseInstruction())); }
public void Ret_ParseCheck_i32_Identifier_Ok() { LValueRef valueRef = new LValueRef(LType.Int32Type(), _function.GetValueRefIdentifier()); LRet ret = new LRet(valueRef); Assert.AreEqual($"{LKeywords.Ret} i32 {valueRef.ValueOrIdentifier}", LHelper.Trim(ret.ParseInstruction())); }
public void Fneg_ParseCheck() { LFneg fneg = new LFneg(_op1, _result); Assert.AreEqual($"{_result.Identifier} = fneg {_result.ParseType()} {_op1.ValueOrIdentifier}", LHelper.Trim(fneg.ParseInstruction())); }
public void AllocaLiteralStruct_Expected_Ok() { var @struct = new LLiteralStruct(new LValueRef(LType.Int128Type(), ""), new LValueRef(LType.Int16Type(), "")); LAlloca alloca = new LAlloca(_function, @struct); Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {{ i128, i16 }}", LHelper.Trim(alloca.ParseInstruction())); Assert.AreEqual("{ i128, i16 }*", LHelper.Trim(alloca.PointerRef.ParseType())); }
public void SimpleAnd_WithConstant_ParseCheck() { LValueRef op2 = new LValueRef(LType.Int32Type(), "12"); LAnd and = new LAnd(_valueResult, _valueOp1, op2); Assert.AreEqual($"{_valueResult.Identifier} = and {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {op2.ValueOrIdentifier}", LHelper.Trim(and.ParseInstruction())); }
public void Fneg_ParseCheck_FastMathFlags() { LFneg fneg = new LFneg(_op1, _result); fneg.Flags.Add(LFastMathFlags.fast); Assert.AreEqual($"{_result.Identifier} = fneg {LFastMathFlags.fast.Parse()} {_result.ParseType()} {_op1.ValueOrIdentifier}", LHelper.Trim(fneg.ParseInstruction())); }
public void SimpleLoadParse_Expected_True() { LLoad load = new LLoad(_function, _alloca.PointerRef); Assert.AreEqual( $"{load.ValueRef.Identifier} = {LKeywords.Load} {LType.Int32Type().Parse()}, {load.PointerRef.ParseType()} {load.PointerRef.Identifier}", LHelper.Trim(load.ParseInstruction())); }
public void UnconditionalBr_ParseCheck() { LUnconditionalBr unconditionalBr = new LUnconditionalBr(_ifTrueLabel); Assert.AreEqual( $"{LKeywords.Br} {LKeywords.Label} {_ifTrueLabel.Identifier}", LHelper.Trim(unconditionalBr.ParseInstruction())); }
public void SimpleLshr_WithConstant_ParseCheck() { LValueRef op2 = new LValueRef(LType.Int32Type(), "12"); LShl shl = new LShl(_valueResult, _valueOp1, op2); Assert.AreEqual($"{_valueResult.Identifier} = shl {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {op2.ValueOrIdentifier}", LHelper.Trim(shl.ParseInstruction())); }
public void Switch_Unconditional_ParseCheck() { LValueRef valueRef = new LValueRef(LType.Int32Type(), "%1"); LLabelType defaultLabel = new LLabelType("%default"); LSwitch @switch = new LSwitch(valueRef, defaultLabel); Assert.AreEqual("switch i32 %1, label %default [ ]", LHelper.Trim(@switch.ParseInstruction())); }
public void AllocaTriplePointerType_Expected_Equal() { LPointerRef singlePointer = new LPointerRef(new LValueRef(LType.Int32Type(), ""), _function.GetPointerRefIdentifier()); LPointerRef doublePointer = new LPointerRef(singlePointer, _function.GetPointerRefIdentifier()); LAlloca alloca = new LAlloca(_function, doublePointer); Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}**", LHelper.Trim(alloca.ParseInstruction())); Assert.AreEqual($"{LType.Int32Type().Parse()}***", LHelper.Trim(alloca.PointerRef.ParseType())); }
public void AllocaIdentifiedStruct_Expected_Ok() { string structIdentifier = "abcTestStruct"; var @struct = new LIdentifiedStruct(structIdentifier, new LValueRef(LType.Int128Type(), ""), new LValueRef(LType.Int16Type(), "")); LAlloca alloca = new LAlloca(_function, @struct); Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {structIdentifier}", LHelper.Trim(alloca.ParseInstruction())); Assert.AreEqual($"{structIdentifier}*", LHelper.Trim(alloca.PointerRef.ParseType())); }
public void SimpleLshr_Exact_ParseCheck() { LLshr lshr = new LLshr(_valueResult, _valueOp1, _valueOp2) { Exact = true }; Assert.AreEqual($"{_valueResult.Identifier} = lshr exact {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {_valueOp2.ValueOrIdentifier}", LHelper.Trim(lshr.ParseInstruction())); }
public void ConditionalBr_ParseCheck() { LValueRef condition = new LValueRef(LType.BoolType(), _function.GetValueRefIdentifier()); LConditionalBr conditionalBr = new LConditionalBr( condition, _ifTrueLabel, _ifFalseLabel); Assert.AreEqual( $"{LKeywords.Br} i1 {condition.ValueOrIdentifier}, {LKeywords.Label} {_ifTrueLabel.Identifier}, {LKeywords.Label} {_ifFalseLabel.Identifier}", LHelper.Trim(conditionalBr.ParseInstruction())); }
public void AllocaParseNumOfElements_Expected_True() { LAlloca alloca = new LAlloca(_function, LType.Int32Type()) { NumOfElements = 5 }; Assert.AreEqual( $"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}, {LType.Int32Type().Parse()} 5", LHelper.Trim(alloca.ParseInstruction())); }
public void SimpleLshr_NuwNsw_ParseCheck() { LShl shl = new LShl(_valueResult, _valueOp1, _valueOp2) { NoUnsignedWrap = true, NoSignedWrap = true, }; Assert.AreEqual($"{_valueResult.Identifier} = shl nuw nsw {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {_valueOp2.ValueOrIdentifier}", LHelper.Trim(shl.ParseInstruction())); }
public void AllocaParseAddrspace_Expected_True() { LAlloca alloca = new LAlloca(_function, LType.Int32Type()) { Addrspace = 4 }; Assert.AreEqual( $"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}, {LKeywords.Addrspace}(4)", LHelper.Trim(alloca.ParseInstruction())); }
public void StoreAlignment_Expected_Ok() { LStore store = new LStore(_src, _dst) { Alignment = 5012 }; Assert.AreEqual( $"{LKeywords.Store} {_src.ParseType()} {_src.ValueOrIdentifier}, {_dst.ParseType()} {_dst.Identifier}, {LKeywords.Align} 5012", LHelper.Trim(store.ParseInstruction())); }
public void StoreIsAtomic_Expected_Ok() { LStore store = new LStore(_src, _dst) { IsAtomic = true }; Assert.AreEqual( $"{LKeywords.Store} {LKeywords.Atomic} {_src.ParseType()} {_src.ValueOrIdentifier}, {_dst.ParseType()} {_dst.Identifier}", LHelper.Trim(store.ParseInstruction())); }
public void LoadParseIsAtomicVolatile_Expected_True() { LLoad load = new LLoad(_function, _alloca.PointerRef) { IsAtomic = true, IsVolatile = true }; Assert.AreEqual( $"{load.ValueRef.Identifier} = {LKeywords.Load} {LKeywords.Atomic} {LKeywords.Volatile} {LType.Int32Type().Parse()}, {load.PointerRef.ParseType()} {load.PointerRef.Identifier}", LHelper.Trim(load.ParseInstruction())); }
public void StoreIsAtomicVolatileAlignment_Hardcoded_Expected_Ok() { LStore store = new LStore(_src, _dst) { IsAtomic = true, IsVolatile = true, Alignment = 5012 }; Assert.AreEqual( $"store atomic volatile i32 {_src.ValueOrIdentifier}, i32* {_dst.Identifier}, align 5012", LHelper.Trim(store.ParseInstruction())); }
public void Switch_ParseCheck() { LValueRef valueRef = new LValueRef(LType.Int32Type(), "%1"); LLabelType defaultLabel = new LLabelType("%default"); LSwitch @switch = new LSwitch(valueRef, defaultLabel); @switch.JumpTableDestinations.Add((0, new LLabelType("%one"))); @switch.JumpTableDestinations.Add((1, new LLabelType("%two"))); @switch.JumpTableDestinations.Add((2, new LLabelType("%three"))); @switch.JumpTableDestinations.Add((3, new LLabelType("%four"))); Assert.AreEqual($"switch i32 %1, label %default [ i32 0, label %one{Environment.NewLine}i32 1, label %two{Environment.NewLine}i32 2, label %three{Environment.NewLine}i32 3, label %four ]", LHelper.Trim(@switch.ParseInstruction())); }
public void Ret_ParseCheck_Void_Ok() { LRet ret = new LRet(new LValueRef(LType.VoidType(), _function.GetValueRefIdentifier())); Assert.AreEqual($"{LKeywords.Ret} {LKeywords.Void}", LHelper.Trim(ret.ParseInstruction())); }