|
11 | 11 | #include "llvm/IR/InlineAsm.h"
|
12 | 12 | #include "llvm/IR/InstrTypes.h"
|
13 | 13 | #include "llvm/IR/Instructions.h"
|
| 14 | +#include "llvm/IR/Intrinsics.h" |
14 | 15 | #include "llvm/IR/Module.h"
|
15 | 16 | #include "llvm/MC/MCContext.h"
|
16 | 17 | #include "llvm/MC/MCSectionELF.h"
|
@@ -50,6 +51,7 @@ enum OpCode {
|
50 | 51 | OpCodePtrAdd,
|
51 | 52 | OpCodeBinOp,
|
52 | 53 | OpCodeCast,
|
| 54 | + OpCodeDeoptSafepoint, |
53 | 55 | OpCodeUnimplemented = 255, // YKFIXME: Will eventually be deleted.
|
54 | 56 | };
|
55 | 57 |
|
@@ -393,6 +395,26 @@ class YkIRWriter {
|
393 | 395 | InstIdx++;
|
394 | 396 | }
|
395 | 397 |
|
| 398 | + void serialiseDeoptSafepointInst(CallInst *I, ValueLoweringMap &VLMap, |
| 399 | + unsigned BBIdx, unsigned &InstIdx) { |
| 400 | + serialiseOpcode(OpCodeDeoptSafepoint); |
| 401 | + // stackmap ID: |
| 402 | + serialiseOperand(I, VLMap, I->getOperand(0)); |
| 403 | + |
| 404 | + // num_shadow_bytes: |
| 405 | + serialiseOperand(I, VLMap, I->getOperand(1)); |
| 406 | + |
| 407 | + // num_lives: |
| 408 | + OutStreamer.emitInt32(I->arg_size() - 2); |
| 409 | + |
| 410 | + // lives: |
| 411 | + for (unsigned OI = 2; OI < I->arg_size(); OI++) { |
| 412 | + serialiseOperand(I, VLMap, I->getOperand(OI)); |
| 413 | + } |
| 414 | + InstIdx++; |
| 415 | + return; |
| 416 | + } |
| 417 | + |
396 | 418 | void serialiseCallInst(CallInst *I, ValueLoweringMap &VLMap, unsigned BBIdx,
|
397 | 419 | unsigned &InstIdx) {
|
398 | 420 | if (I->isInlineAsm()) {
|
@@ -426,7 +448,13 @@ class YkIRWriter {
|
426 | 448 | // call i32 (i32, ...) @f(1i32, 2i32);
|
427 | 449 | assert(I->getCalledFunction());
|
428 | 450 |
|
429 |
| - // opcode: |
| 451 | + // special case for llvm.experimental.stackmap intrinsic. |
| 452 | + if (I->getCalledFunction()->isIntrinsic() && |
| 453 | + I->getIntrinsicID() == Intrinsic::experimental_stackmap) { |
| 454 | + serialiseDeoptSafepointInst(I, VLMap, BBIdx, InstIdx); |
| 455 | + return; |
| 456 | + } |
| 457 | + |
430 | 458 | serialiseOpcode(OpCodeCall);
|
431 | 459 | // callee:
|
432 | 460 | OutStreamer.emitSizeT(functionIndex(I->getCalledFunction()));
|
|
0 commit comments