@@ -197,6 +197,57 @@ def LabelOp : RTGOp<"label", []> {
197197 let assemblyFormat = "$visibility $label attr-dict";
198198}
199199
200+ //===- Context Operations -------------------------------------------------===//
201+
202+ def OnContextOp : RTGOp<"on_context", []> {
203+ let summary = "places a sequence on a context";
204+ let description = [{
205+ This operation takes a context and a fully substituted, but not yet
206+ randomized sequence and inserts the necessary instructions to switch from
207+ the current context to the provided context, randomizes and embeds the given
208+ sequence under the given context, and inserts instructions to switch back to
209+ the original context.
210+
211+ These instructions are provided by the 'rtg.context_switch' operation. If no
212+ 'rtg.context_switch' for this transition is provided, the compiler will
213+ error out. If multiple such context switches apply, the most recently
214+ registered one takes precedence.
215+ }];
216+
217+ let arguments = (ins ContextResourceTypeInterface:$context,
218+ FullySubstitutedSequenceType:$sequence);
219+
220+ let assemblyFormat = [{
221+ $context `,` $sequence `:` qualified(type($context)) attr-dict
222+ }];
223+ }
224+
225+ def ContextSwitchOp : RTGOp<"context_switch", [
226+ HasParent<"rtg::TargetOp">,
227+ ]> {
228+ let summary = "a specification of how to switch contexts";
229+ let description = [{
230+ This operation allows the user to specify a sequence of instructions to
231+ switch from context 'from' to context 'to', randomize and embed a provided
232+ sequence, and switch back from context 'to' to context 'from'. This
233+ sequence of instructions should be provided as the 'sequence' operand which
234+ is a sequence of the type '!rtg.sequence<context-type-interface,
235+ context-type-interface, !rtg.sequence>'. The first parameter is the 'from'
236+ context, the second one the 'to' context, and the third is the sequence to
237+ randomize and embed under the 'to' context.
238+ }];
239+
240+ let arguments = (ins ContextResourceAttrInterface:$from,
241+ ContextResourceAttrInterface:$to,
242+ SequenceType:$sequence);
243+
244+ let assemblyFormat = [{
245+ $from `->` $to `,` $sequence `:` qualified(type($sequence)) attr-dict
246+ }];
247+
248+ let hasVerifier = 1;
249+ }
250+
200251//===- Set Operations ------------------------------------------------------===//
201252
202253def SetCreateOp : RTGOp<"set_create", [Pure, SameTypeOperands]> {
0 commit comments