Compile the regular expression pattern pattern, returning a pointer to the compiled object for later matching with the internal regex engine.

This function is typically used by a custom regexp engine .comp() function to hand off to the core regexp engine those patterns it doesn't want to handle itself (typically passing through the same flags it was called with). In almost all other cases, a regexp should be compiled by calling "pregcomp" to compile using the currently active regexp engine.

If pattern is already a REGEXP, this function does nothing but return a pointer to the input. Otherwise the PV is extracted and treated like a string representing a pattern. See perlre.

The possible flags for rx_flags are documented in perlreapi. Their names all begin with RXf_.

This routine is expected to clone a given regexp structure. It is only compiled under USE_ITHREADS.

After all of the core data stored in struct regexp is duplicated the regexp_engine.dupe method is used to copy any private data stored in the *pprivate pointer. This allows extensions to handle any duplication they need to do.